dxkOrder.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. // pages/mall/dxkOrder/dxkOrder.js
  2. var app = getApp();
  3. var WxParse = require('../../../lib/wxParse/wxParse.js');
  4. var util = require('../../../utils/util.js');
  5. var mall = require('../../../api/mall.js');
  6. var user = require('../../../utils/user.js');
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. skuText:"39元语音版:2500分钟语音+40GB通用流量+30GB定向流量",
  13. region: ['上海市', '上海市', '浦东新区'],
  14. customItem: '全部',
  15. showModal: false,
  16. phoneList:['13873344047','13873344048','13873344049','13873344168','13873344169','13873344100','13873344120','13873344121','13873344122','13873344123'],
  17. tempPhone:"",
  18. phone:"",
  19. isSelectedIndex:'',
  20. isPhone:false,
  21. currentSkuId:'',
  22. workerInfo:{},
  23. isChecked:false,
  24. installedAddress:"",
  25. contactMobile:"",
  26. goodId:"",
  27. isSelect:true
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad(options) {
  33. console.log(options)
  34. this.setData({
  35. currentSkuId: options.currentSkuId,
  36. goodId: options.goodId
  37. })
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady() {
  43. },
  44. /**
  45. * 生命周期函数--监听页面显示
  46. */
  47. onShow() {
  48. this.getDetailInfo()
  49. },
  50. getDetailInfo(){
  51. let that=this;
  52. wx.showLoading({
  53. title: '加载中',
  54. });
  55. util.request(mall.getDetailInfo, {
  56. skuId: that.data.currentSkuId
  57. }).then(function (res) {
  58. wx.hideLoading();
  59. if (res.errno == 0) {
  60. that.setData({
  61. skuText: res.data.wmsSkuProperty.propertyValue,
  62. workerInfo: res.data.workerSupplier,
  63. });
  64. } else if (res.errno == 501) {
  65. wx.redirectTo({
  66. url: "/pages/auth/login/login"
  67. });
  68. } else {
  69. wx.showToast({
  70. title: res.errmsg,
  71. duration: 5000
  72. })
  73. }
  74. });
  75. },
  76. selectNumber:function(e){
  77. let that=this;
  78. let params={
  79. skuId:that.data.currentSkuId
  80. }
  81. wx.showLoading({
  82. title: '加载中',
  83. });
  84. util.request(mall.selectNumber,params,'post').then(function (res) {
  85. wx.hideLoading();
  86. if (res.errno == 0) {
  87. that.setData({
  88. phoneList: res.data
  89. });
  90. } else if (res.errno == 501) {
  91. wx.redirectTo({
  92. url: "/pages/auth/login/login"
  93. });
  94. } else {
  95. wx.showToast({
  96. title: res.errmsg,
  97. duration: 5000
  98. })
  99. }
  100. });
  101. this.setData({
  102. showModal:true
  103. })
  104. },
  105. bindRegionChange: function (e) {
  106. console.log('picker发送选择改变,携带值为', e.detail.value)
  107. this.setData({
  108. region: e.detail.value
  109. })
  110. },
  111. hideModal:function(){
  112. this.setData({
  113. showModal:false
  114. })
  115. },
  116. selectdNumber(e){
  117. let index=e.currentTarget.dataset.index
  118. this.setData({
  119. isSelectedIndex:e.currentTarget.dataset.index,
  120. tempPhone: e.currentTarget.dataset.num
  121. })
  122. },
  123. selectedPhone(e){
  124. this.setData({
  125. phone: this.data.tempPhone,
  126. showModal: false,
  127. isPhone: true
  128. })
  129. },
  130. checkChange(e){
  131. console.log(e)
  132. this.setData({
  133. isChecked: e.detail,
  134. });
  135. },
  136. checkboxChange(e) {
  137. if(e.detail.value=="true"){
  138. this.setData({
  139. isChecked : true,
  140. isSelect:false
  141. })
  142. }else{
  143. this.setData({
  144. isChecked : false,
  145. isSelect:true
  146. })
  147. }
  148. },
  149. checkProBtn() {
  150. wx.navigateTo({
  151. url: '/pages/mall/dxkOrderXy/dxkOrderXy'
  152. })
  153. },
  154. inputAddress(e){
  155. this.setData({
  156. installedAddress : e.detail.value
  157. })
  158. },
  159. inputPhone(e){
  160. this.setData({
  161. contactMobile : e.detail.value
  162. })
  163. },
  164. saveOrder(){
  165. if(this.data.phone==""){
  166. util.showErrorToast('请选择手机号!');
  167. return false;
  168. }
  169. if(this.data.region[0]=="全部" || this.data.region[1]=="全部" || this.data.region[2]=="全部"){
  170. util.showErrorToast('请选择正确的省市区!');
  171. return false;
  172. }
  173. if(this.data.installedAddress==""){
  174. util.showErrorToast('请输入详细地址!');
  175. return false;
  176. }
  177. if(this.data.contactMobile==""){
  178. util.showErrorToast('请输入联系手机号!');
  179. return false;
  180. }
  181. if(!this.data.isChecked){
  182. util.showErrorToast('请阅读并同意入网协议!');
  183. return false;
  184. }
  185. let that=this;
  186. wx.showLoading({
  187. title: '加载中',
  188. });
  189. let params={
  190. name: that.data.workerInfo.workerName,
  191. idCard: that.data.workerInfo.workerIdcard,
  192. workerNo: that.data.workerInfo.workerNo,
  193. contactMobile: that.data.contactMobile,
  194. province: that.data.region[0],
  195. city: that.data.region[1],
  196. county: that.data.region[2],
  197. installedAddress: that.data.installedAddress,
  198. number:that.data.phone.replaceAll("-",""),
  199. skuId: that.data.currentSkuId,
  200. goodId: that.data.goodId
  201. }
  202. util.request(mall.saveOrder,params,'post').then(function (res) {
  203. wx.hideLoading();
  204. if (res.errno == 0) {
  205. wx.showToast({
  206. title: "领取成功",
  207. duration: 2000
  208. })
  209. wx.redirectTo({
  210. url: "/pages/mall/order/order"
  211. });
  212. } else if (res.errno == 501) {
  213. wx.redirectTo({
  214. url: "/pages/auth/login/login"
  215. });
  216. } else {
  217. wx.showToast({
  218. title: res.errmsg,
  219. duration: 5000
  220. })
  221. }
  222. });
  223. },
  224. /**
  225. * 生命周期函数--监听页面隐藏
  226. */
  227. onHide() {
  228. },
  229. /**
  230. * 生命周期函数--监听页面卸载
  231. */
  232. onUnload() {
  233. },
  234. /**
  235. * 页面相关事件处理函数--监听用户下拉动作
  236. */
  237. onPullDownRefresh() {
  238. },
  239. /**
  240. * 页面上拉触底事件的处理函数
  241. */
  242. onReachBottom() {
  243. },
  244. /**
  245. * 用户点击右上角分享
  246. */
  247. onShareAppMessage() {
  248. }
  249. })