pay.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. var __request = require('../../utils/request.js')
  2. var _handle = require('../../utils/handle.js')
  3. var validator = require('../../utils/validator.js')
  4. Page({
  5. data: {
  6. orderId: 0,
  7. payData: {},
  8. address: null,
  9. pick_address: null,
  10. selectaddress:false,
  11. selectpickaddress:false,
  12. balanceInfo: {},
  13. centInfo:{},
  14. cashInfo:{},
  15. userInfo: {},
  16. radish: 0,
  17. pwd: '',
  18. pwdDialog: false,
  19. useRadishSelect: false,
  20. useRadishSelectVal: 'select',
  21. showModal: false,
  22. luoboCount: '',
  23. countMoney: '',
  24. curPayway: 'weixinpay',
  25. payway: {
  26. weixin: 'weixinpay',
  27. balance: 'balance',
  28. cent: 'cent'
  29. },
  30. total:0,
  31. yunfei:0,
  32. _yunfei:0,
  33. payFlag:false,
  34. useBalance:false,
  35. afterdec:0,//使用提货券扣除后的总额
  36. remark:'',
  37. receivetype:0,//提货方式
  38. pickdepartsList:[],
  39. repickdepartsList:[],
  40. pickindex:0,
  41. pickid:0,
  42. has_unuse_quan:false,
  43. use_silver:0,
  44. pay_cash:0//佣金抵扣
  45. },
  46. onLoad: function (options) {
  47. this.data.orderId = options.orderId;
  48. this.getOrderInfo()
  49. // this.getBalanceInfo()
  50. wx.setStorageSync('use_address', false);
  51. wx.setStorageSync('use_pick_address', false);
  52. wx.setStorageSync('receivetype', 0);
  53. this.getpickdeparts();
  54. },
  55. onShow: function () {
  56. this.getUserInfo()
  57. var receivetype = wx.getStorageSync('receivetype');
  58. if(receivetype == 0){
  59. var address = wx.getStorageSync('use_address');
  60. if(address){
  61. this.setData({
  62. address: address,
  63. selectaddress:true,
  64. receivetype : receivetype,
  65. yunfei : this.data._yunfei
  66. });
  67. }
  68. }else{
  69. var address = wx.getStorageSync('use_pick_address');
  70. if(address){
  71. this.setData({
  72. pick_address: address,
  73. selectpickaddress:true,
  74. receivetype : receivetype,
  75. yunfei : 0
  76. });
  77. }
  78. }
  79. this.setData({
  80. payFlag: false
  81. })
  82. },
  83. inputPwd: function (e) {
  84. this.setData({
  85. pwd: e.detail.value
  86. })
  87. },
  88. checkboxChange: function (e) {
  89. if (e.detail.value[0]) {
  90. this.setData({
  91. useRadishSelect: true,
  92. useRadishSelectVal: 'select'
  93. })
  94. } else {
  95. this.setData({
  96. useRadishSelect: false
  97. })
  98. }
  99. },
  100. getOrderInfo: function () {
  101. var that = this
  102. var url = "v1/order/" + that.data.orderId;
  103. var params = {}
  104. var check_has_unuse_quan = false;
  105. var success = function (val) {
  106. if (val.data && val.data.product && !val.data.product.robo_balance_price) {
  107. that.setData({
  108. curPayway: 'weixinpay'
  109. })
  110. }
  111. var total = 0;
  112. for(var i in val.data.product_list){
  113. if(!val.data.product_list[i].send) total = total + (val.data.product_list[i].price * val.data.product_list[i].count)
  114. }
  115. var canusebalance = 0;
  116. var nousebalance = 0;
  117. var use_silver = 0;
  118. for(var i in val.data.product_list){
  119. var item = val.data.product_list[i];
  120. if(!item.send){
  121. if(val.data.special_promotion){//新增双十一促销判断
  122. canusebalance = canusebalance + (item.price * item.count);
  123. }else{
  124. // if(item.pv >= item.price){
  125. // canusebalance = canusebalance + (item.price * item.count);
  126. // }else{
  127. // nousebalance = nousebalance + (item.price * item.count);
  128. // }
  129. if(!item.use_quan){
  130. nousebalance = nousebalance + (item.price * item.count);
  131. check_has_unuse_quan = true;
  132. }else{
  133. canusebalance = canusebalance + (item.price * item.count);
  134. }
  135. }
  136. use_silver = use_silver + item.silver;
  137. }
  138. }
  139. console.log('canusebalance',canusebalance);
  140. console.log('nousebalance',nousebalance);
  141. that.setData({
  142. payData: val.data,
  143. project: val.data.product_list,
  144. total:total,
  145. yunfei:that.data.receivetype == 0 ? total<9900?val.data.freight:0 : 0,
  146. _yunfei:total<9900?val.data.freight:0,
  147. canusebalance:canusebalance,
  148. nousebalance:nousebalance,
  149. has_unuse_quan:check_has_unuse_quan,
  150. use_silver:use_silver,
  151. disAmount:val.data.dis_amount
  152. });
  153. if(that.data.payData.order_type == 3){
  154. that.getCentInfo();
  155. }else{
  156. that.getCashInfo();
  157. }
  158. if(val.data.pay_way != '' && (val.data.address_id != 0 || val.data.pick_dept != 0)){
  159. if(val.data.pick_way == 0){
  160. that.getAddress(val.data.address_id);
  161. that.setData({
  162. selectaddress:true,
  163. receivetype : val.data.pick_way,
  164. yunfei : val.data.freight,
  165. remark : val.data.remark
  166. });
  167. }else{
  168. // that.getPickAddress(val.data.pick_dept);
  169. var pid = 0;
  170. for(var i = 0;i<that.data.pickdepartsList.length;i++){
  171. if(that.data.pickdepartsList[i]['id'] == val.data.pick_dept) pid = i;
  172. }
  173. var _pick_address = {
  174. contact:val.data.contact,
  175. tel:val.data.tel
  176. }
  177. that.setData({
  178. selectpickaddress:true,
  179. receivetype : val.data.pick_way,
  180. yunfei : 0,
  181. pick_address:_pick_address,
  182. pickindex:pid,
  183. pickid:that.data.payData.pick_dept,
  184. remark : val.data.remark
  185. });
  186. }
  187. }
  188. }
  189. __request.$get(url, params, success)
  190. },
  191. getDefaultAddress: function () {
  192. var that = this
  193. var url = "v1/user/address/default";
  194. var params = {}
  195. var success = function (val) {
  196. if (val.data !== null) {
  197. that.setData({
  198. address: val.data
  199. });
  200. }
  201. }
  202. __request.$get(url, params, success)
  203. },
  204. getCashInfo: function(){
  205. var that = this
  206. var url = "v1/user/cash/balance/info";
  207. var params = {}
  208. var success = function (res) {
  209. console.log('res.data',res.data)
  210. that.setData({
  211. cashInfo: res.data
  212. })
  213. that.getBalanceInfo();
  214. }
  215. __request.$get(url, params, success)
  216. },
  217. getBalanceInfo: function () {
  218. var that = this
  219. var url = "v1/user/balance/info";
  220. var params = {}
  221. var success = function (val) {
  222. // console.log('showusebalance:',(val.data.total > 0 && that.data.payData.order_type == 0))
  223. //获取订单最高可用银豆
  224. var max_silver = that.data.payData.total_silver;
  225. //获取账户持有银豆
  226. // var user_silver = val.data.silver_total;
  227. // var use_silver = 0;//使用银豆
  228. // if(user_silver > 0){
  229. // use_silver = user_silver >= max_silver ? max_silver : user_silver;
  230. // }
  231. //新直接使用计算好的值
  232. var use_silver = that.data.use_silver;
  233. //总额和canuse&nouse减去银豆
  234. var has_balance = val.data.total;
  235. var sour_total = that.data.total;
  236. var mins_total = that.data.total - use_silver;
  237. var mins_canuse = that.data.canusebalance;
  238. var mins_nouse = that.data.nousebalance;
  239. var left_silver = use_silver;
  240. var afterdec = 0;
  241. var dis_amount = 0;
  242. //
  243. sour_total = sour_total - use_silver;
  244. //canuse的扣除银豆
  245. if(mins_canuse - use_silver < 0){
  246. mins_canuse = 0;
  247. left_silver = use_silver - mins_canuse;
  248. }else{
  249. mins_canuse = mins_canuse - use_silver;
  250. left_silver = 0;
  251. }
  252. console.log('mins_canuse',mins_canuse);
  253. console.log('left_silver',left_silver);
  254. //nouse的扣除剩余的银豆
  255. if(mins_nouse - left_silver < 0){
  256. mins_nouse = 0;
  257. left_silver = left_silver - mins_nouse;
  258. }else{
  259. mins_nouse = mins_nouse - left_silver;
  260. left_silver = 0;
  261. }
  262. console.log('left_silver',left_silver);
  263. //新增剩余的根据等级和订单类型做折扣
  264. // if(val.data.show_invite_mode == 1 && that.data.payData.order_type == 0){//店长可以享受优惠
  265. // var disbi = val.data.discount_bl == 0? 100 : val.data.discount_bl;
  266. // sour_total = sour_total * (disbi/100);
  267. // dis_amount = parseInt(mins_total - (mins_total * (disbi/100)));
  268. // mins_canuse = mins_canuse * (disbi/100);
  269. // mins_nouse = mins_nouse * (disbi/100);
  270. // }
  271. //新已减银豆
  272. if(that.data.payData.pay_way == ''){
  273. if(that.data.receivetype == 0){
  274. if(parseInt(has_balance) >= parseInt(mins_canuse) + parseInt(that.data.yunfei)){
  275. console.log('1');
  276. afterdec = mins_nouse;
  277. }else{
  278. console.log('2');
  279. afterdec = Math.abs((mins_canuse + that.data.yunfei)-has_balance) + mins_nouse;
  280. }
  281. }else{
  282. if(parseInt(has_balance) >= parseInt(mins_canuse)){
  283. console.log('3');
  284. afterdec = mins_nouse;
  285. }else{
  286. console.log('4');
  287. afterdec = Math.abs((mins_canuse)-has_balance) + mins_nouse;
  288. }
  289. }
  290. }else{
  291. console.log('5');
  292. // afterdec = (that.data.total - that.data.payData.paied_silver - that.data.payData.dis_amount)+that.data.yunfei-that.data.payData.coupon_price;
  293. afterdec = that.data.total + that.data.yunfei - that.data.payData.paied_silver - that.data.payData.coupon_price -that.data.payData.dis_amount;
  294. }
  295. var source_afterdec = afterdec;
  296. //canuse的扣除银豆
  297. // mins_canuse = mins_canuse - use_silver < 0 ? 0 : mins_canuse - use_silver;
  298. // left_silver = mins_canuse - use_silver < 0 ? use_silver - mins_canuse : 0;
  299. // //nouse的扣除剩余的银豆
  300. // mins_nouse = mins_nouse - left_silver < 0 ? 0 : mins_nouse - left_silver;
  301. // left_silver = mins_nouse - left_silver < 0 ? left_silver - mins_nouse : 0;
  302. console.log('afterdec',afterdec);
  303. console.log('mins_canuse',mins_canuse);
  304. console.log('mins_nouse',mins_nouse);
  305. console.log('left_silver',left_silver);
  306. console.log('sour_total',sour_total);
  307. //旧未减银豆
  308. // if(that.data.payData.pay_way == ''){
  309. // if(that.data.receivetype == 0){
  310. // if(parseInt(val.data.total) >= parseInt(that.data.canusebalance) + parseInt(that.data.yunfei)){
  311. // afterdec = that.data.nousebalance;
  312. // }else{
  313. // afterdec = Math.abs((that.data.canusebalance + that.data.yunfei)-val.data.total) + that.data.nousebalance;
  314. // }
  315. // }else{
  316. // if(parseInt(val.data.total) >= parseInt(that.data.canusebalance)){
  317. // afterdec = that.data.nousebalance;
  318. // }else{
  319. // afterdec = Math.abs((that.data.canusebalance)-val.data.total) + that.data.nousebalance;
  320. // }
  321. // }
  322. // }else{
  323. // afterdec = that.data.total+that.data.yunfei-that.data.payData.coupon_price;
  324. // }
  325. var minus_cash = 0;
  326. var trueafter = afterdec - that.data.payData.dis_amount;
  327. if(that.data.cashInfo.total > 0 && trueafter > 0){
  328. minus_cash = that.data.cashInfo.total < trueafter ? that.data.cashInfo.total : trueafter;
  329. }
  330. console.log('minus_cash',minus_cash);
  331. that.setData({
  332. balanceInfo: val.data,
  333. cache: false,
  334. // curPayway:val.data.total >= (that.data.total + that.data.yunfei)?'balance':'weixinpay'
  335. curPayway:'weixinpay',
  336. // useBalance:(val.data.total > 0 && that.data.payData.order_type == 0 && that.data.payData.pv >= that.data.payData.total_price)? true:false,
  337. useBalance: /* (val.data.total > 0 && that.data.payData.order_type == 0) || */ !that.data.payData.shut_wechat ? true:false,
  338. afterdec: afterdec,
  339. hasSeilver: val.data.silver_total,
  340. useSeilver: use_silver - left_silver,
  341. minusTotal: sour_total,
  342. discountBl: val.data.discount_bl,
  343. sourceAfterdec: source_afterdec,
  344. pay_cash: minus_cash
  345. // disAmount:dis_amount
  346. });
  347. }
  348. __request.$get(url, params, success)
  349. },
  350. getCentInfo: function () {
  351. var that = this
  352. var url = "v1/user/cent/info";
  353. var params = {}
  354. var success = function (val) {
  355. // console.log('showusebalance:',(val.data.total > 0 && that.data.payData.order_type == 0))
  356. that.setData({
  357. centInfo: val.data,
  358. cache: false,
  359. curPayway:'cent',
  360. useBalance:false,
  361. afterdec:that.data.receivetype == 0 ? parseInt(val.data.total) >= parseInt(that.data.total) + parseInt(that.data.yunfei)?'0':(that.data.total + that.data.yunfei)-val.data.total : 0
  362. });
  363. }
  364. __request.$get(url, params, success)
  365. },
  366. switchChange:function(e){
  367. var that = this;
  368. that.setData({
  369. useBalance:e.detail.value
  370. })
  371. },
  372. getUserInfo: function () {
  373. var that = this
  374. var url = "v1/user/info";
  375. var params = {
  376. cache: false
  377. }
  378. var success = function (val) {
  379. that.setData({
  380. userInfo: val.data
  381. });
  382. }
  383. __request.$get(url, params, success)
  384. },
  385. cancelDialog: function () {
  386. this.setData({
  387. pwdDialog: false
  388. })
  389. },
  390. toPay: function (e) {
  391. if(this.data.payFlag){
  392. wx.showToast({
  393. title: '支付中,请稍后...',
  394. icon: 'none',
  395. duration: 2000
  396. })
  397. return false;
  398. }
  399. _handle.setFormId(e)
  400. var that = this
  401. this.setData({
  402. payFlag: true
  403. })
  404. if (that.data.receivetype == 0 && !that.data.address) {
  405. wx.showToast({
  406. title: '请先填写地址',
  407. icon: 'none',
  408. duration: 2000
  409. })
  410. that.setData({
  411. payFlag: false
  412. })
  413. } else if (that.data.receivetype == 0 && !validator.required1(this.data.address.contact)) {
  414. wx.showToast({
  415. title: '国家安全局规定:运单禁止出现“先生”,“小姐”,“女士”等,请重新填写地址',
  416. icon: 'none',
  417. duration: 2000
  418. })
  419. that.setData({
  420. payFlag: false
  421. })
  422. }else if (that.data.receivetype == 1 && !that.data.pick_address) {
  423. wx.showToast({
  424. title: '请先选择提货人',
  425. icon: 'none',
  426. duration: 2000
  427. })
  428. that.setData({
  429. payFlag: false
  430. })
  431. }else if (that.data.receivetype == 1 && !that.data.pickid) {
  432. wx.showToast({
  433. title: '请选择自提门店',
  434. icon: 'none',
  435. duration: 2000
  436. })
  437. that.setData({
  438. payFlag: false
  439. })
  440. } else {
  441. if (that.data.curPayway === 'balance') {
  442. var p
  443. if (that.data.project) {
  444. p = that.data.balanceInfo.total - that.data.project.robo_balance_price * that.data.payData.count
  445. }
  446. if (p < 0) {
  447. this.setData({
  448. luoboCount: -(that.data.balanceInfo.total - that.data.project.robo_balance_price * that.data.payData.count),
  449. showModal: true,
  450. countMoney: -(that.data.balanceInfo.total - that.data.project.robo_balance_price * that.data.payData.count) / 100,
  451. payFlag: false
  452. })
  453. } else {
  454. that.pay()
  455. }
  456. } else if (that.data.curPayway === 'cent') {
  457. // var b
  458. // if (that.data.project) {
  459. // b = that.data.balanceInfo.dc_total - that.data.project.mall_balance_price * that.data.payData.count
  460. // }
  461. // if (b < 0) {
  462. // this.setData({
  463. // luoboCount: that.data.project.mall_balance_price * that.data.payData.count - that.data.balanceInfo.dc_total,
  464. // showModal: true,
  465. // payFlag: false
  466. // })
  467. // } else {
  468. that.pay()
  469. // }
  470. } else if (that.data.curPayway === 'weixinpay') {
  471. // if(that.data.useBalance && that.data.afterdec > 0){
  472. // wx.showModal({
  473. // title: '提示',
  474. // content: '订单将抵扣 '+ (that.data.payData.coupon_price>0?that.data.payData.coupon_price/100:((that.data.total+that.data.yunfei)-that.data.afterdec) / 100)+' 元提货券,剩下 '+(that.data.afterdec / 100)+' 元将由微信支付,祝您购物愉快!' ,
  475. // success: function (sm) {
  476. // if (sm.confirm) {
  477. // that.pay()
  478. // } else if (sm.cancel) {
  479. // console.log('用户点击取消')
  480. // that.setData({
  481. // payFlag: false
  482. // })
  483. // }
  484. // }
  485. // })
  486. // }else{
  487. that.pay()
  488. // }
  489. }
  490. // if (!that.data.userInfo.user.has_trade_pwd) {
  491. // that.setPwdDialog()
  492. // } else {
  493. // if (that.data.balanceInfo.total - that.data.project.price * that.data.payData.count < 0) {
  494. // this.setData({
  495. // luoboCount: -(that.data.balanceInfo.total - that.data.project.price * that.data.payData.count),
  496. // showModal: true,
  497. // countMoney: -(that.data.balanceInfo.total - that.data.project.price * that.data.payData.count) / 100
  498. // })
  499. // } else {
  500. // that.setData({
  501. // pwdDialog: true
  502. // })
  503. // if (that.data.useRadishSelect) {
  504. // that.setData({
  505. // pwdDialog: true
  506. // })
  507. // } else {
  508. // that.openToast('请勾选使用提货券兑换~')
  509. // }
  510. // }
  511. // }
  512. }
  513. },
  514. onCancel: function () {
  515. this.setData({
  516. showModal: false
  517. });
  518. },
  519. onConfirm: function () {
  520. wx.navigateTo({
  521. url: '/packageUser/pages/user/exchange/exchange'
  522. })
  523. },
  524. onConfirm1: function() {
  525. wx.navigateTo({
  526. url: '/packageUser/pages/user/buy/buy?path=/pages/pay/pay&orderId=' + this.data.orderId +
  527. '&luoboCount=' + this.data.luoboCount + '&countMoney=' + this.data.countMoney
  528. })
  529. // /pages/pay/pay?order_id=EX201807206A91F25E
  530. },
  531. onConfirm2: function () {
  532. wx.navigateTo({
  533. url: '/pages/parse/parse?id=8'
  534. })
  535. },
  536. preventTouchMove: function () {
  537. },
  538. selectClick: function (e) {
  539. var that = this
  540. that.setData({
  541. curPayway: e.target.dataset.payway
  542. });
  543. },
  544. pay: function () {
  545. var that = this
  546. var url = "v1/pay";
  547. var params;
  548. if(that.data.receivetype == 0){
  549. params = {
  550. pick_way: 0,
  551. order_id: that.data.orderId,
  552. trad_pwd: that.data.pwd,
  553. pay_way: that.data.curPayway,
  554. address_id: that.data.address.id,
  555. s: 'xcx',
  556. use_coupon:that.data.useBalance,
  557. remark:that.data.remark
  558. }
  559. }else{
  560. params = {
  561. pick_way: 1,
  562. order_id: that.data.orderId,
  563. trad_pwd: that.data.pwd,
  564. pay_way: that.data.curPayway,
  565. s: 'xcx',
  566. use_coupon:that.data.useBalance,
  567. remark:that.data.remark,
  568. pick_dept:that.data.pickid,
  569. pick_addr_id:that.data.pick_address.id
  570. }
  571. }
  572. console.log('onpay',params)
  573. var success = function (val) {
  574. console.log(val);
  575. if(val.statusCode === 200){
  576. if (that.data.curPayway === 'weixinpay' && val.data.need_wx) {
  577. wx.requestPayment({
  578. 'timeStamp': val.data.pay_data.timeStamp,
  579. 'nonceStr': val.data.pay_data.nonceStr,
  580. 'package': val.data.pay_data.package,
  581. 'signType': val.data.pay_data.signType,
  582. 'paySign': val.data.pay_data.paySign,
  583. 'success':function(res){
  584. wx.showToast({
  585. title: '支付成功',
  586. icon: 'success',
  587. duration: 1000
  588. })
  589. wx.navigateTo({
  590. // url: '/packageUser/pages/user/orders/orders'
  591. url: '/pages/projects/project-success/project-success?id=' + that.data.orderId
  592. })
  593. },
  594. 'fail':function(res){
  595. that.setData({
  596. payFlag: false
  597. })
  598. that.getOrderInfo()
  599. }
  600. })
  601. } else {
  602. that.setData({
  603. pay: val.data
  604. });
  605. wx.redirectTo({
  606. // url: '/packageUser/pages/user/orders/orders'
  607. url: '/pages/projects/project-success/project-success?id=' + that.data.orderId
  608. })
  609. }
  610. that.setData({
  611. payFlag: false
  612. })
  613. that.getOrderInfo()
  614. }else{
  615. that.setData({
  616. payFlag: false
  617. })
  618. that.getOrderInfo()
  619. }
  620. }
  621. var fail = function(err){
  622. that.setData({
  623. payFlag: false
  624. })
  625. }
  626. __request.$post(url, params, success, fail)
  627. },
  628. setPwdDialog: function () {
  629. wx.showModal({
  630. title: '提示',
  631. confirmColor: '#eab86a',
  632. content: '您未设置交易密码,是否前往设置?',
  633. success: function(res) {
  634. if (res.confirm) {
  635. wx.navigateTo({
  636. url: '/packageUser/pages/user/safe/safe'
  637. })
  638. } else if (res.cancel) {
  639. }
  640. }
  641. })
  642. },
  643. onShareAppMessage: function (val) {
  644. return _request.share({
  645. sc: 'xcx_pay'
  646. })
  647. },
  648. bindremark (e) {
  649. this.setData({
  650. remark: e.detail.value
  651. })
  652. },
  653. receivetbn(e){
  654. if(this.data.payData.pay_way == ''){
  655. this.setData({
  656. receivetype: e.target.dataset.value,
  657. yunfei : e.target.dataset.value == 0 ? this.data._yunfei : 0
  658. })
  659. wx.setStorageSync('receivetype', e.target.dataset.value) //存入
  660. this.getBalanceInfo()
  661. }else{
  662. wx.showToast({
  663. title: '当前提货方式已确定',
  664. icon: 'none',
  665. duration: 2000
  666. })
  667. }
  668. },
  669. getpickdeparts: function () {
  670. var that = this
  671. var url = "v1/pick_departs";
  672. var params = {}
  673. var success = function (val) {
  674. console.log('pick_departs-val',val);
  675. let list = [];
  676. for(var i in val.data){
  677. list.push(val.data[i]['pick_address']+'-'+val.data[i]['pick_title'])
  678. }
  679. that.setData({
  680. pickdepartsList:val.data,
  681. repickdepartsList:list,
  682. pickindex: 0,
  683. pickid:val.data[0]?val.data[0]['id']:0
  684. })
  685. }
  686. __request.$get(url, params, success)
  687. },
  688. bindPickerChange: function(e) {
  689. var that = this;
  690. console.log('picker发送选择改变,携带值为', e.detail.value)
  691. this.setData({
  692. pickindex: e.detail.value,
  693. pickid:that.data.pickdepartsList[e.detail.value]['id']
  694. })
  695. },
  696. getAddress(id) {
  697. var that = this
  698. var url = 'v1/address/'
  699. var params = {
  700. }
  701. var success = function (res) {
  702. var setaddress;
  703. for(var i in res.data){
  704. if(res.data[i]['id'] == id){
  705. setaddress = res.data[i];
  706. }
  707. }
  708. that.setData({
  709. address:setaddress
  710. })
  711. }
  712. __request.$get(url, params, success)
  713. },
  714. getPickAddress(id) {
  715. var that = this
  716. var url = 'v1/pick_address'
  717. var params = {
  718. }
  719. var success = function (res) {
  720. var setaddress;
  721. for(var i in res.data){
  722. if(res.data[i]['id'] == id){
  723. setaddress = res.data[i];
  724. }
  725. }
  726. that.setData({
  727. pick_address:setaddress
  728. })
  729. }
  730. __request.$get(url, params, success)
  731. }
  732. })