confirmOrder.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. const app = getApp()
  2. const api = require('../../../../request/api');
  3. const http = require('../../../../request/http');
  4. const utils = require('../../../../utils/util.js');
  5. const storeKeys = require('../../../../utils/storageKeys.js');
  6. Page({
  7. data: {
  8. isIphoneX: app.globalData.isIphoneX,
  9. isLoading: true, //是否处于加载
  10. mode: 'buyNow', //页面来源
  11. dataParams: {}, //参数对象
  12. model_addr: false,
  13. goodsObj: {}, //商品返回数据
  14. addressId: '', //地址id
  15. isDisabled: false, //是否禁用按钮
  16. remark: '', //备注
  17. orderId: '',
  18. buyNumber: 1, //购买数量
  19. buySelfNumber: 1, //自提购买数量
  20. cardModel: false,
  21. riceList: [],
  22. riceCardId: 0, //确认选中的米卡
  23. riceCardCheckItem: {}, //选择使用的米卡
  24. isCommit: false,
  25. orderType: 10, //配送方式 默认10 10-快递配送 20-门店自提
  26. formeType: 1, //1:拼团 2:裂变拼团 3:秒杀
  27. couponModel:false, //是否显示优惠卷弹窗
  28. couponList:[], //优惠卷列表
  29. couponId: 0, //确认选中的优惠卷id
  30. couponCheckItem: {}, //确认选中的优惠卷
  31. couponMoney:'0.00', //确认选中的优惠价格
  32. discountModel: false, //是否显示优惠明细弹窗
  33. showZpLowStock: false, // 赠品库存不足
  34. kimmyModel:false, //金米粒抵扣弹窗
  35. isUseGoldRice: 1, //是否使用金米粒 -1禁用 0不使用 1使用
  36. },
  37. onLoad: function (options) {
  38. if (options.data) {
  39. let dataObj = JSON.parse(options.data)
  40. if(dataObj.mode==='groupbuylb'){
  41. this.data.formeType = 2
  42. }
  43. console.log(dataObj)
  44. this.setData({
  45. dataParams: dataObj,
  46. mode: dataObj.mode,
  47. buyNumber: dataObj.goodsNum,
  48. buySelfNumber: dataObj.goodsNum,
  49. })
  50. console.log(this.data.mode)
  51. }
  52. },
  53. //切换配送方式
  54. changeTitleTab(e) {
  55. let index = e.currentTarget.dataset.index;
  56. if (index == this.data.orderType) {
  57. return;
  58. }
  59. this.setData({
  60. orderType: index,
  61. ['dataParams.goodsNum']: index == 10 ? this.data.buyNumber : this.data.buySelfNumber
  62. })
  63. this.getData();
  64. },
  65. //增加/删减购买数量 线上物流
  66. changeGoodsNumber: utils.throttle(function (e) {
  67. let state = e.currentTarget.dataset.state;
  68. let item = e.currentTarget.dataset.item;
  69. let buyNumber = this.data.buyNumber;
  70. if(this.dataParams.mode=='za'){
  71. return;
  72. }
  73. // console.log(item)
  74. // state:1增加 0删减
  75. if (state == 1) {
  76. if (item.skuInfo.stock_num <= 0) {
  77. utils.toast("库存不足")
  78. return;
  79. }
  80. if (buyNumber >= item.skuInfo.stock_num) {
  81. utils.toast("不能再加了,达到商品最大库存了")
  82. return;
  83. }
  84. buyNumber++
  85. } else {
  86. if (buyNumber <= 1) {
  87. utils.toast("不能再减了")
  88. return;
  89. }
  90. buyNumber--
  91. }
  92. this.setData({
  93. buyNumber,
  94. ['dataParams.goodsNum']: buyNumber
  95. })
  96. this.getData()
  97. }, 500),
  98. //增加/删减购买数量 门店自提
  99. changeGoodsSelfNumber: utils.throttle(function (e) {
  100. let state = e.currentTarget.dataset.state;
  101. let item = e.currentTarget.dataset.item;
  102. let buySelfNumber = this.data.buySelfNumber;
  103. if (state == 1) {
  104. if (item.skuInfo.stock_num <= 0) {
  105. utils.toast("库存不足")
  106. return;
  107. }
  108. if (buySelfNumber >= item.skuInfo.stock_num) {
  109. utils.toast("不能再加了,达到商品最大库存了")
  110. return;
  111. }
  112. buySelfNumber++
  113. } else {
  114. if (buySelfNumber <= 1) {
  115. utils.toast("不能再减了")
  116. return;
  117. }
  118. buySelfNumber--
  119. }
  120. this.setData({
  121. buySelfNumber,
  122. ['dataParams.goodsNum']: buySelfNumber
  123. })
  124. this.getData()
  125. }, 500),
  126. //监听商品数量输入 线上物流
  127. changeBuyNumber(e) {
  128. let buyNumber = e.detail.value.replace(/\s+/g, '');
  129. this.setData({
  130. buyNumber,
  131. ['dataParams.goodsNum']: buyNumber
  132. })
  133. },
  134. //监听商品数量输入 门店自提
  135. changeBuySelfNumber(e) {
  136. let buySelfNumber = e.detail.value.replace(/\s+/g, '');
  137. this.setData({
  138. buySelfNumber,
  139. ['dataParams.goodsNum']: buySelfNumber
  140. })
  141. },
  142. //商品数量输入失去焦点 线上物流
  143. numberBlur(e) {
  144. //输入的数量大于库存数时
  145. let item = e.currentTarget.dataset.item,
  146. that = this;
  147. if (parseInt(this.data.buyNumber) > parseInt(item.skuInfo.stock_num)) {
  148. this.setData({
  149. buyNumber: item.skuInfo.stock_num,
  150. ['dataParams.goodsNum']: item.skuInfo.stock_num
  151. })
  152. }
  153. setTimeout(() => {
  154. that.getData()
  155. }, 200)
  156. },
  157. //商品数量输入失去焦点 门店自提
  158. selfnumberBlur(e) {
  159. //输入的数量大于库存数时
  160. let item = e.currentTarget.dataset.item,
  161. that = this;
  162. if (parseInt(this.data.buySelfNumber) > parseInt(item.skuInfo.stock_num)) {
  163. this.setData({
  164. buySelfNumber: item.skuInfo.stock_num,
  165. ['dataParams.goodsNum']: item.skuInfo.stock_num
  166. })
  167. }
  168. setTimeout(() => {
  169. that.getData()
  170. }, 200)
  171. },
  172. toAddr() {
  173. wx.navigateTo({
  174. url: "/pages/user/pages/addressList/addressList?sourceState=1"
  175. })
  176. },
  177. detailInput: function (e) {
  178. this.setData({
  179. remark: e.detail.value
  180. })
  181. },
  182. //获取订单列表
  183. getData() {
  184. let that = this;
  185. wx.showLoading({
  186. title: "加载中",
  187. mask: true
  188. });
  189. let url = '',
  190. dataParams = this.data.dataParams
  191. if (!dataParams.goodsSkuId) {
  192. dataParams.goodsSkuId = 0
  193. }
  194. //本地分享人id
  195. let staffUserId = utils.getStorageSync(storeKeys.SHAREID) || utils.getStorageSync(storeKeys.APPLESID) || "";
  196. // 推广监控ID
  197. let promotionMonitorId = utils.getStorageSync(storeKeys.SOURECID) || 0;
  198. /**
  199. * dataParams参数详解
  200. * mode:下单模式 buyNow:商品详情立即下单 bargain:砍价活动下单 cart:购物车下单
  201. * goodsId:商品id
  202. * goodsSkuId:商品规则id
  203. * goodsNum:购买数量
  204. * cartIds:购物车id集合(字符串逗号隔开)
  205. * addressId:用户选用的收获地址id
  206. * riceCardId:用户选用的米卡id 不使用传-1
  207. * couponId:用户选用的优惠券id 不使用传-1
  208. * staffUserId:上级推广人id
  209. * orderType:配送方式 默认10 10-快递配送 20-门店自提
  210. * isUseGoldRice:是否使用金米粒 默认1 -1禁用 0不使用 1使用
  211. * promotionMonitorId:渠道推广id
  212. */
  213. if(this.data.isUseGoldRice == -1){
  214. this.data.isUseGoldRice = 1;
  215. }
  216. //商品详情立即下单
  217. if (this.data.mode == 'buyNow') {
  218. url = '/api/checkout/order?mode=' + dataParams.mode + '&goodsId=' + dataParams.goodsId + '&goodsSkuId=' + dataParams.goodsSkuId +
  219. '&goodsNum=' + dataParams.goodsNum + '&addressId=' + this.data.addressId + '&riceCardId=' + this.data.riceCardId + '&couponId='+this.data.couponId +
  220. '&staffUserId=' + staffUserId + '&delivery=' + this.data.orderType+'&isUseGoldRice='+this.data.isUseGoldRice + "&promotionMonitorId="+promotionMonitorId
  221. } else if(this.data.mode == 'bargain'){
  222. //砍价活动下单
  223. url = '/api/checkout/order?mode=' + dataParams.mode + '&goodsId=' + dataParams.goodsId + '&goodsSkuId=' + dataParams.goodsSkuId +
  224. '&goodsNum=' + dataParams.goodsNum + '&addressId=' + this.data.addressId + '&bargainId=' + dataParams.bargainId +
  225. '&staffUserId=' + staffUserId + '&riceCardId=' + this.data.riceCardId + '&delivery=' + this.data.orderType+'&isUseGoldRice='+this.data.isUseGoldRice + "&promotionMonitorId="+promotionMonitorId
  226. }else if(this.data.mode == 'miaosha'){
  227. //秒杀活动下单
  228. url = '/api/checkout/order?mode=' + dataParams.mode + '&goodsId=' + dataParams.goodsId + '&goodsSkuId=' + dataParams.goodsSkuId +
  229. '&goodsNum=' + dataParams.goodsNum + '&addressId=' + this.data.addressId +
  230. '&staffUserId=' + staffUserId + '&delivery=' + this.data.orderType + '&msId=' + dataParams.msId
  231. console.log(url)
  232. }else if(this.data.mode == 'za'){
  233. // 买一赠一订单
  234. url = '/api/checkout/order?mode=' + dataParams.mode + '&goodsId=' + dataParams.goodsId + '&goodsSkuId=' + dataParams.goodsSkuId +
  235. '&goodsNum=' + dataParams.goodsNum + '&addressId=' + this.data.addressId +
  236. '&staffUserId=' + staffUserId + '&delivery=' + this.data.orderType + '&zaGoodsId=' + dataParams.zaGoodsId + '&riceCardId=' + this.data.riceCardId
  237. console.log(url)
  238. }else if(this.data.mode == 'zareceive'){
  239. // 买一赠一领取
  240. url = '/api/checkout/order?mode=' + dataParams.mode + '&addressId=' + this.data.addressId +
  241. '&staffUserId=' + staffUserId + '&signStr=' + dataParams.signStr
  242. console.log(url)
  243. }else if(this.data.mode == 'pointsExchange'){
  244. // 积分兑换
  245. url = '/api/checkout/order?mode=' + dataParams.mode + '&goodsId=' + dataParams.goodsId + '&goodsSkuId=' + dataParams.goodsSkuId +
  246. '&goodsNum=' + dataParams.goodsNum+
  247. '&staffUserId=' + staffUserId
  248. console.log(url)
  249. }
  250. else {
  251. // 购物车下单
  252. url = '/api/checkout/order?mode=' + dataParams.mode + '&cartIds=' + dataParams.cartIds + '&addressId=' + this.data.addressId +
  253. '&riceCardId=' + this.data.riceCardId +'&couponId='+this.data.couponId+ '&staffUserId=' + staffUserId +
  254. '&delivery=' + this.data.orderType+'&isUseGoldRice='+this.data.isUseGoldRice + "&promotionMonitorId="+promotionMonitorId
  255. }
  256. // http://ysctest.cookhome.club/api/checkout/order?mode=za&cartIds=undefined&addressId=&riceCardId=0&couponId=0&staffUserId=&delivery=10&isUseGoldRice=1&promotionMonitorId=0
  257. http.request({
  258. url: api.URL + url,
  259. method: 'GET',
  260. token: utils.getStorageSync(storeKeys.TOKEN),
  261. success: (res) => {
  262. console.log(res)
  263. wx.hideLoading();
  264. let orderObj = res.data.data.order;
  265. if (this.data.orderType == 20 && !orderObj.isPickup) {
  266. this.setData({
  267. orderType: 10,
  268. ['goodsObj.isPickup']: false
  269. })
  270. return;
  271. }
  272. //来源直接购买 切换时库存大于输入库存时 重新赋值输入的值
  273. if (this.data.mode == "buyNow") {
  274. let goodsList = orderObj.goodsList || []
  275. let buyNumber = this.data.buyNumber;
  276. let buySelfNumber = this.data.buySelfNumber;
  277. for (let i = 0; i < goodsList.length; i++) {
  278. let item = goodsList[i];
  279. if (!item.stock_enough) {
  280. // 商品类型,10普通商品;20赠品;30套餐商品
  281. if(item.goods_type != 20){
  282. if(this.data.orderType == 20){
  283. this.setData({
  284. buySelfNumber: item.skuInfo.stock_num || buySelfNumber
  285. })
  286. }else{
  287. this.setData({
  288. buyNumber: item.skuInfo.stock_num || buyNumber
  289. })
  290. }
  291. this.setData({
  292. ['dataParams.goodsNum']: item.skuInfo.stock_num
  293. })
  294. }
  295. break;
  296. }
  297. }
  298. }
  299. //选中的优惠价id
  300. let couponId = res.data.data.order.couponId;
  301. let couponCheckItem = {couponId};
  302. //选中的米卡id
  303. let riceCardId = res.data.data.order.riceCardId;
  304. let riceCardCheckItem = {id:riceCardId}
  305. //赋予是否选用金米粒默认值
  306. let isUseGoldRice = res.data.data.order.isUseGoldRice;
  307. this.setData({
  308. goodsObj: res.data.data.order,
  309. couponMoney:res.data.data.order.couponMoney,
  310. couponId,
  311. riceCardId,
  312. couponCheckItem,
  313. riceCardCheckItem,
  314. isLoading: false,
  315. riceList: res.data.data.order.userRiceCardList,
  316. couponList: res.data.data.order.couponList,
  317. isUseGoldRice
  318. })
  319. if (orderObj.errorStatus == 423 || orderObj.hasError || orderObj.errorStatus == 424) {
  320. this.setData({
  321. isDisabled: true
  322. })
  323. } else {
  324. this.setData({
  325. isDisabled: false
  326. })
  327. }
  328. if (orderObj.errorStatus == 423) {
  329. this.setData({
  330. model_addr: true
  331. })
  332. } else if (orderObj.errorStatus == 424) {
  333. this.setData({
  334. showZpLowStock: true
  335. })
  336. } else {
  337. this.setData({
  338. model_addr: false,
  339. showZpLowStock: false
  340. })
  341. }
  342. },
  343. error: (res) => {},
  344. })
  345. },
  346. // 清除无货商品
  347. cleanInvalidGoods: utils.throttle(function (e) {
  348. let invalidGoodsList = this.data.goodsObj.invalidGoodsList || [];
  349. let cartIds = [];
  350. invalidGoodsList && invalidGoodsList.forEach((item) => {
  351. cartIds.push(item.cart_id);
  352. })
  353. console.log(cartIds)
  354. let data = {
  355. cartIds
  356. }
  357. wx.showLoading({
  358. title: "加载中"
  359. });
  360. http.request({
  361. url: api.URL + '/api/cart/delete',
  362. method: 'POST',
  363. data,
  364. token: utils.getStorageSync(storeKeys.TOKEN),
  365. success: (res) => {
  366. this.getData();
  367. },
  368. error: (res) => {
  369. wx.hideLoading();
  370. utils.toast(res.data.message)
  371. },
  372. })
  373. }),
  374. clickModel() {
  375. this.setData({
  376. model_addr: false
  377. })
  378. },
  379. commit: utils.throttle(function (e) {
  380. if (this.data.orderType == 20 && this.data.goodsObj.invalidGoodsList && this.data.goodsObj.invalidGoodsList.length > 0) {
  381. utils.toast("请先清除无货商品!")
  382. return;
  383. }
  384. let that = this;
  385. if(this.data.orderType == 10 && !this.data.goodsObj.address){
  386. utils.toast("请先填写收货地址")
  387. return;
  388. }
  389. wx.showLoading({
  390. title: "加载中"
  391. });
  392. //本地分享人id
  393. let staffUserId = utils.getStorageSync(storeKeys.SHAREID) || utils.getStorageSync(storeKeys.APPLESID) || "";
  394. let dataParams = this.data.dataParams
  395. dataParams.addressId = this.data.addressId
  396. dataParams.remark = this.data.remark
  397. dataParams.riceCardId = this.data.riceCardId
  398. dataParams.couponId = this.data.couponId
  399. dataParams.delivery = this.data.orderType
  400. dataParams.staffUserId = staffUserId
  401. dataParams.isUseGoldRice=this.data.isUseGoldRice
  402. if (!dataParams.goodsSkuId) {
  403. dataParams.goodsSkuId = 0
  404. }
  405. /**
  406. * 对接地址:https://ad.weixin.qq.com/main.html#/docs/232
  407. * 参数说明地址:https://ad.weixin.qq.com/main.html#/docs/232?branch_id=2IhtO
  408. * clickId 存在则是来源微信广告
  409. */
  410. let clickId = utils.getStorageSync(storeKeys.CLICKID) || "";
  411. if(clickId){
  412. let pages = getCurrentPages()
  413. let currentPage = pages[pages.length-1]
  414. dataParams.adUrl = "http://www."+"/"+currentPage.route
  415. dataParams.adClickId = clickId
  416. }
  417. // 推广监控ID
  418. let promotionMonitorId = utils.getStorageSync(storeKeys.SOURECID)
  419. console.log("下单监控id"+promotionMonitorId)
  420. if(promotionMonitorId){
  421. dataParams.promotionMonitorId = promotionMonitorId
  422. }
  423. console.log(dataParams)
  424. http.request({
  425. url: api.URL + '/api/checkout/submit',
  426. method: 'POST',
  427. token: utils.getStorageSync(storeKeys.TOKEN),
  428. data: dataParams,
  429. success: (res) => {
  430. wx.hideLoading();
  431. let orderId = res.data.data.order_id
  432. // "pay_type": 20, //支付类型 10余额支付 20微信支付 30现金卡支付 40买一赠一领取
  433. if (res.data.data.pay_type == 20) {
  434. that.setData({
  435. isCommit: true
  436. })
  437. that.wxPayment(res.data.data.payment, orderId);
  438. }
  439. if (res.data.data.pay_type == 30 || res.data.data.pay_type == 40 || res.data.data.pay_type == 50) {
  440. utils.toast('支付成功');
  441. app.getCartNumber();
  442. that.toNextPage(orderId)
  443. }
  444. },
  445. error: (res) => {
  446. console.log(res)
  447. that.setData({
  448. isDisabled: true
  449. })
  450. },
  451. })
  452. }, 800),
  453. toNextPage(orderId){
  454. let url = "/pages/cart/pages/paySuccess/paySuccess?orderType=" + this.data.orderType + "&orderId=" + orderId
  455. if(this.data.mode == 'za'){
  456. url = url + '&type=3'
  457. }
  458. if(this.data.mode == 'zareceive'){
  459. url = url + '&zareceive=1'
  460. }
  461. wx.reLaunch({
  462. url: url
  463. })
  464. },
  465. //调起微信支付
  466. wxPayment(data, orderId) {
  467. let _this = this;
  468. wx.requestPayment({
  469. nonceStr: data.nonceStr,
  470. package: 'prepay_id=' + data.prepay_id,
  471. paySign: data.paySign,
  472. signType: "MD5",
  473. timeStamp: data.timeStamp,
  474. success(res) {
  475. if (res.errMsg == "requestPayment:ok") {
  476. app.getCartNumber();
  477. utils.toast('支付成功');
  478. _this.toNextPage(orderId);
  479. // wx.reLaunch({
  480. // url: "/pages/cart/pages/paySuccess/paySuccess?orderType=" + _this.data.orderType
  481. // })
  482. }
  483. },
  484. fail(res) {
  485. if (res.errMsg == "requestPayment:fail cancel") {
  486. app.getCartNumber();
  487. utils.toast('已取消支付');
  488. // wx.reLaunch({
  489. // url: "/pages/cart/pages/noPayment/noPayment?orderId=" + orderId
  490. // })
  491. }
  492. }
  493. })
  494. },
  495. // 选择米卡
  496. toCheckRiceCard() {
  497. //选中的米卡id
  498. let riceCardId = this.data.goodsObj.riceCardId;
  499. let riceCardCheckItem = {id:riceCardId}
  500. this.setData({
  501. cardModel: true,
  502. riceCardCheckItem
  503. })
  504. },
  505. hideModel() {
  506. this.setData({
  507. cardModel: false
  508. })
  509. },
  510. checkRiceCard(e) {
  511. let item0 = {
  512. id: -1
  513. }
  514. let item = e.currentTarget.dataset.item || item0;
  515. console.log(item)
  516. this.setData({
  517. riceCardCheckItem: item
  518. })
  519. },
  520. confirmRiceCard() {
  521. console.log(this.data.riceCardCheckItem.id)
  522. if (!this.data.riceCardCheckItem.id) {
  523. utils.toast("请选择要使用的米卡")
  524. return;
  525. }
  526. this.setData({
  527. cardModel: false,
  528. riceCardId: this.data.riceCardCheckItem.id
  529. })
  530. this.getData()
  531. },
  532. //选择优惠券
  533. checkCoupon(e) {
  534. let couponId = e.currentTarget.dataset.id || -1;
  535. let couponCheckItem = {couponId}
  536. this.setData({
  537. couponCheckItem
  538. })
  539. },
  540. //确认优惠券
  541. confirmCoupon() {
  542. if (!this.data.couponCheckItem.couponId) {
  543. utils.toast("请选择要使用的优惠券")
  544. return;
  545. }
  546. this.setData({
  547. couponModel: false,
  548. couponId: this.data.couponCheckItem.couponId
  549. })
  550. this.getData()
  551. },
  552. onShow: function () {
  553. if (this.data.isCommit) {
  554. return;
  555. }
  556. this.getData()
  557. },
  558. //弹出选择优惠卷
  559. couponModel(){
  560. if(!this.data.couponList || this.data.couponList.length <= 0){
  561. return;
  562. }
  563. let couponId = this.data.goodsObj.couponId;
  564. let couponCheckItem = {couponId};
  565. this.setData({
  566. couponModel:true,
  567. couponCheckItem
  568. })
  569. },
  570. //隐藏选择优惠券
  571. hideCouponModel(){
  572. this.setData({
  573. couponModel: false
  574. })
  575. },
  576. //取消下单
  577. cancel: utils.throttle(function (e) {
  578. wx.navigateBack({
  579. delta: 1
  580. })
  581. }),
  582. //显示优惠详情
  583. showDiscountModel(){
  584. this.setData({
  585. discountModel:true
  586. })
  587. },
  588. //隐藏优惠详情
  589. hideDiscountModel(){
  590. this.setData({
  591. discountModel:false
  592. })
  593. },
  594. // 无赠品弹窗 返回上一页
  595. closeZpModel() {
  596. wx.navigateBack({
  597. delta: 1,
  598. })
  599. },
  600. //显示选择金米粒
  601. showKimmyModel(){
  602. this.setData({
  603. kimmyModel:true,
  604. isUseGoldRice:this.data.goodsObj.isUseGoldRice
  605. })
  606. },
  607. //隐藏选择金米粒
  608. hideKimmyModel(){
  609. this.setData({
  610. kimmyModel:false
  611. })
  612. },
  613. //切换选择金米粒
  614. checkKimmy(e) {
  615. //禁用金米粒
  616. if(this.data.goodsObj.isUseGoldRice == -1){
  617. return;
  618. }
  619. let isUseGoldRice = e.currentTarget.dataset.id || 0;
  620. this.setData({
  621. isUseGoldRice
  622. })
  623. },
  624. //确认金米粒
  625. confirmKimmy() {
  626. this.setData({
  627. kimmyModel: false
  628. })
  629. //禁用金米粒
  630. if(this.data.goodsObj.isUseGoldRice == -1){
  631. return;
  632. }
  633. console.log(this.data.isUseGoldRice)
  634. this.getData()
  635. },
  636. })