integral.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. // pages/integral/integral.js
  2. import Integralinfo from '../../api/integralinfo'
  3. import {getMobileCache, getPhoneNumberNew as getPhoneNumberSync} from '../../utils/user'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. lock: false,
  10. noResult: false,
  11. noMore: false,
  12. bannerList: [],
  13. couponList: [],
  14. channelid: '',
  15. shopid: '',
  16. storeid: '',
  17. bodyHidden: true,
  18. bgStatus: false,
  19. scorePhone: false,
  20. animationData: {},
  21. integralIngo:{},
  22. loading: false,
  23. setPhone: '',
  24. current: '',
  25. integralNum: 0,
  26. phone: '********',
  27. // phone: '15888282621',
  28. mobile: '********',
  29. paymentStatus: false,
  30. paymentBgStatus: false,
  31. activeNum: 0,
  32. listTrue: [],
  33. listStatus: false,
  34. total: 0,
  35. row: {},
  36. codeName: '60s后重新获取',
  37. codeTime: '',
  38. active1obj: {
  39. orderId: '',
  40. order_no: '',
  41. step: ''
  42. },
  43. active1code: '',
  44. active2code: '',
  45. tgid: '',
  46. scene: '',
  47. noClick: true,
  48. showToastObj: {
  49. icon: '',
  50. title: '',
  51. status: false
  52. },
  53. isIphoneX:false,
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad: function (options) {
  59. var reg = /^(\d{3})\d{4}(\d{4})$/;
  60. this.setData({
  61. isLogin: getMobileCache() != '',
  62. phone: getMobileCache() == ''?'********':getMobileCache().replace(reg, "$1****$2"),
  63. setPhone: getMobileCache(),
  64. mobile: getMobileCache(),
  65. channelid: options.channelid === undefined ? '' : options.channelid,
  66. shopid: options.shopid === undefined ? '' : options.shopid,
  67. storeid: options.storeid === undefined ? '' : options.storeid,
  68. tgid: options.tgid === undefined ? '' : options.tgid,
  69. })
  70. },
  71. /**
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. let _self = this;
  81. this.setData({
  82. isIphoneX:_self.isIphone()
  83. })
  84. this.getBannerList()
  85. // 获取优惠券列表
  86. this.getCouponList()
  87. if(getMobileCache() != ''){
  88. Integralinfo.getBalance({
  89. mobile: getMobileCache(),
  90. callbackUrl: '../integral/integral.wxml',
  91. fingerprint: '',
  92. sessionid: '',
  93. shopid: this.data.shopid,
  94. type: 'wx',
  95. }).then(arr => {
  96. if (arr.code === '0000') {
  97. var reg = /^(\d{3})\d{4}(\d{4})$/;
  98. this.setData({
  99. isLogin: getMobileCache() != '',
  100. phone: getMobileCache() == ''?'********':getMobileCache().replace(reg, "$1****$2"),
  101. setPhone: getMobileCache(),
  102. mobile: getMobileCache(),
  103. integralNum: arr.data,
  104. })
  105. }
  106. }).catch(error=>{
  107. console.log(error);
  108. })
  109. }
  110. },
  111. /**
  112. * 判断是否是iphone
  113. */
  114. isIphone() {
  115. let isIphone = false
  116. wx.getSystemInfo({
  117. success: function(res) {
  118. if (res.model.indexOf('iPhone') >= 0) {
  119. isIphone = true;
  120. }
  121. }
  122. })
  123. return isIphone
  124. },
  125. /**
  126. * 生命周期函数--监听页面隐藏
  127. */
  128. onHide: function () {
  129. },
  130. /**
  131. * 生命周期函数--监听页面卸载
  132. */
  133. onUnload: function () {
  134. },
  135. /**
  136. * 页面相关事件处理函数--监听用户下拉动作
  137. */
  138. onPullDownRefresh: function () {
  139. },
  140. /**
  141. * 页面上拉触底事件的处理函数
  142. */
  143. onReachBottom: function () {
  144. },
  145. /**
  146. * 用户点击右上角分享
  147. */
  148. onShareAppMessage: function () {
  149. },
  150. getBannerList: function() {
  151. Integralinfo.getBannerList({
  152. channelid: this.data.channelid,
  153. shopid: this.data.shopid,
  154. storeid: this.data.storeid
  155. }).then(res => {
  156. console.log(res.data)
  157. this.setData({
  158. bannerList: res.data
  159. })
  160. }).catch(err => {
  161. console.log(err)
  162. })
  163. },
  164. getCouponList: function() {
  165. Integralinfo.getList({
  166. channelid: this.data.channelid,
  167. shopid: this.data.shopid,
  168. storeid: this.data.storeid
  169. }).then(res => {
  170. this.couponListView(res.data)
  171. this.data.lock = false
  172. }).catch(_ => {
  173. console.log(_)
  174. this.data.lock = false
  175. })
  176. },
  177. couponListView: function(data) {
  178. if (!Array.isArray(data) || data.length == 0) {
  179. console.log("优惠券列表数据为空");
  180. }
  181. data.forEach((v) => {
  182. v.quantity = 0
  183. v.integral = v.price * v.ratio
  184. })
  185. if (this.data.mobile != '********') {
  186. let num = this.data.integralNum > 20000 ? 19999 : this.data.integralNum
  187. const arr = []
  188. this.setData({
  189. total: 0,
  190. })
  191. for (let i = 0; i < data.length; i++) {
  192. data[i].quantity = parseInt(num / data[i].integral)
  193. if (data[i].quantity > 0) {
  194. num -= (data[i].quantity * data[i].price) * data[i].ratio
  195. this.data.total += (data[i].quantity * data[i].price) * data[i].ratio
  196. this.setData({
  197. total:this.data.total
  198. })
  199. arr.push(data[i])
  200. data.splice(i, 1)
  201. i--
  202. }
  203. }
  204. this.setData({
  205. couponList: [...arr, ...data]
  206. })
  207. } else {
  208. this.setData({
  209. couponList: data
  210. })
  211. }
  212. console.log(this.data.total)
  213. },
  214. // 点击标识点触发
  215. detailsClick(row) {
  216. this.hideModal();
  217. this.row = row.currentTarget.dataset.info
  218. console.log(this.row)
  219. if (this.row.detail_type === 0) {
  220. this.row.detailArr = this.row.detail.split('\n')
  221. } else {
  222. this.row.detailArr = row.detail
  223. }
  224. this.setData({
  225. integralIngo: this.row,
  226. })
  227. console.log(this.data.integralIngo)
  228. setTimeout(() => {
  229. this.showDodal();
  230. }, 100)
  231. },
  232. showDodal() {
  233. var that = this;
  234. // 显示遮罩层
  235. var animation = wx.createAnimation({
  236. duration: 150,
  237. timingFunction: "linear",
  238. delay: 0
  239. })
  240. this.setData({
  241. bgStatus: true,
  242. bodyHidden: false
  243. })
  244. that.animation = animation
  245. animation.translateY(-500).step()
  246. that.setData({
  247. animationData: animation.export()
  248. })
  249. },
  250. //隐藏对话框
  251. hideModal() {
  252. var that = this;
  253. console.log(that.data)
  254. // 隐藏遮罩层
  255. var animation = wx.createAnimation({
  256. duration: 150,
  257. timingFunction: "linear",
  258. delay: 0
  259. })
  260. this.setData({
  261. bodyHidden: true,
  262. bgStatus: false,
  263. scorePhone: false,
  264. })
  265. that.animation = animation
  266. animation.translateY(0).step()
  267. that.setData({
  268. animationData: animation.export()
  269. })
  270. },
  271. /**授权手机号 */
  272. getPhoneNumber(e) {
  273. let that = this;
  274. getPhoneNumberSync(e, async () => {
  275. console.log(e)
  276. if (getMobileCache() == '') {
  277. wx.showToast({
  278. icon:'error',
  279. title:'先查询移动积分'
  280. })
  281. setTimeout(()=>{
  282. that.data.setPhone = ''
  283. that.scoreClick()
  284. wx.hideLoading()
  285. },500)
  286. } else {
  287. var reg = /^(\d{3})\d{4}(\d{4})$/;
  288. this.setData({
  289. isLogin: true,
  290. setPhone: getMobileCache(),
  291. mobile: getMobileCache(),
  292. phone: getMobileCache().replace(reg, "$1****$2")
  293. })
  294. // console.log(this.data.setPhone)
  295. // console.log(this.data.mobile)
  296. // console.log(this.data.phone)
  297. this.getphoneClick()
  298. }
  299. })
  300. },
  301. // 查询积分
  302. scoreClick() {
  303. this.setData({
  304. bgStatus: true,
  305. scorePhone: true,
  306. })
  307. },
  308. // 查询积分
  309. getphoneClick() {
  310. console.log(getMobileCache())
  311. if (!(/^1[3456789]\d{9}$/.test(getMobileCache()))) {
  312. wx.showToast({
  313. title: '填写正确手机号',
  314. icon: 'error',
  315. duration: 2000
  316. });
  317. } else if (getMobileCache() != '') {
  318. // wx.showLoading({
  319. // title: '加载中'
  320. // });
  321. Integralinfo.getBalance({
  322. mobile: getMobileCache(),
  323. callbackUrl: '../integral/integral.wxml',
  324. fingerprint: '',
  325. sessionid: '',
  326. shopid: this.data.shopid,
  327. type: 'wx',
  328. }).then(arr => {
  329. console.log(arr)
  330. wx.hideLoading();
  331. if (arr.code === '0000') {
  332. var reg = /^(\d{3})\d{4}(\d{4})$/;
  333. this.setData({
  334. integralNum: arr.data,
  335. setPhone: getMobileCache(),
  336. phone: getMobileCache().replace(reg, "$1****$2"),
  337. })
  338. // this.data.integralNum = arr.data
  339. // var reg = /^(\d{3})\d{4}(\d{4})$/;
  340. // this.data.mobile = this.data.setPhone
  341. // this.data.setPhone = this.data.setPhone.replace(reg, "$1****$2");
  342. let response = {
  343. points: arr.data,
  344. outTokenId: this.data.setPhone + '_out'
  345. }
  346. // App.globalData.AppShow = response
  347. this.hideModal()
  348. this.getCouponList()
  349. wx.pageScrollTo({
  350. scrollTop: 0
  351. });
  352. let dateNum = Math.round(new Date().getTime() / 1000).toString()
  353. if (wx.getStorageSync('orderDetails') != '' && this.data.mobile === JSON.parse(wx
  354. .getStorageSync('orderDetails')).mobile) {
  355. if (dateNum - JSON.parse(wx.getStorageSync('orderDetails')).date <= 120) {
  356. const data = JSON.parse(wx.getStorageSync('orderDetails'))
  357. if (dateNum - data.date < 60) {
  358. let time = dateNum - data.date
  359. this.data.codeName = 60 - time + 's后重新获取'
  360. this.codeSetInterval(60 - time)
  361. } else {
  362. this.data.codeName = '重新获取验证码'
  363. }
  364. this.setData({
  365. paymentStatus: true,
  366. paymentBgStatus: true,
  367. active1code: '',
  368. active2code: '',
  369. active1obj: data,
  370. })
  371. if (data.step === 1) {
  372. this.setData({
  373. activeNum: 1,
  374. })
  375. } else if (data.step === 2) {
  376. this.setData({
  377. activeNum: 0,
  378. })
  379. }
  380. }
  381. }
  382. } else {
  383. this.setData({
  384. loading: true,
  385. bgStatus: true
  386. })
  387. setTimeout(() => {
  388. // #ifdef H5
  389. window.location.href = arr.message;
  390. // #endif
  391. // #ifdef MP-WEIXIN
  392. const version = wx.getSystemInfoSync().SDKVersion
  393. if (this.compareVersion(version, '2.20.1') >= 0) {
  394. wx.openEmbeddedMiniProgram({
  395. appId: arr.data.appId,
  396. path: arr.data.path,
  397. extraData: arr.data.extraData,
  398. success(res) {
  399. // 打开成功
  400. },
  401. fail() {}
  402. })
  403. } else {
  404. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  405. wx.navigateToMiniProgram({
  406. appId: arr.data.appId,
  407. path: arr.data.path,
  408. extraData: arr.data.extraData,
  409. success(res) {
  410. // 打开成功
  411. },
  412. fail() {
  413. }
  414. })
  415. }
  416. // #endif
  417. this.hideModal()
  418. this.loading = false
  419. }, 4000)
  420. }
  421. }).catch(error => {
  422. console.log(error)
  423. })
  424. }
  425. },
  426. // 商品数量减少按钮
  427. reduceClick(e) {
  428. console.log(e.currentTarget.dataset.index)
  429. let index = e.currentTarget.dataset.index
  430. this.data.couponList[index].quantity--
  431. this.data.total -= parseInt(this.data.couponList[index].integral)
  432. this.setData({
  433. total: this.data.total,
  434. couponList: this.data.couponList
  435. })
  436. },
  437. // 商品数量添加按钮
  438. addClick(e) {
  439. let index = e.currentTarget.dataset.index
  440. if (this.data.phone !== '********') {
  441. if (this.data.total + parseInt(this.data.couponList[index].integral) > 20000) {
  442. wx.showToast({
  443. title: '单笔限额两万分',
  444. icon: 'error',
  445. duration: 2000
  446. });
  447. } else if ((this.data.integralNum - this.data.total) >= this.data.couponList[index].integral) {
  448. this.data.couponList[index].quantity++
  449. this.data.total += parseInt(this.data.couponList[index].integral)
  450. this.setData({
  451. total: this.data.total,
  452. couponList:this.data.couponList
  453. })
  454. } else {
  455. wx.showToast({
  456. title: '积分不足',
  457. icon: 'error',
  458. duration: 2000
  459. });
  460. }
  461. } else {
  462. wx.showToast({
  463. title: '先查询移动积分',
  464. icon: 'error',
  465. duration: 1000
  466. });
  467. setTimeout(() => {
  468. this.scoreClick()
  469. }, 1000)
  470. }
  471. },
  472. /** 刷新 */
  473. shuaxinClick() {
  474. Integralinfo.getBalance({
  475. mobile: getMobileCache(),
  476. callbackUrl: '../integral/integral.wxml',
  477. fingerprint: '',
  478. sessionid: '',
  479. shopid: this.data.shopid,
  480. type: 'wx',
  481. }).then(arr => {
  482. if (arr.code === '0000') {
  483. wx.hideLoading();
  484. wx.showToast({
  485. title: '查询成功!',
  486. icon: 'success',
  487. duration: 1000
  488. });
  489. var reg = /^(\d{3})\d{4}(\d{4})$/;
  490. this.setData({
  491. integralNum: arr.data,
  492. setPhone: getMobileCache(),
  493. phone: getMobileCache().replace(reg, "$1****$2"),
  494. })
  495. }
  496. }).catch(error=>{
  497. console.log(222222)
  498. console.log(error)
  499. })
  500. },
  501. // 支付按钮
  502. paymentClick() {
  503. console.log(this.data.mobile)
  504. if (this.data.mobile === '********') {
  505. setTimeout(() => {
  506. this.scoreClick()
  507. }, 1000)
  508. wx.showToast({
  509. title: '先查询移动积分',
  510. icon: 'error',
  511. duration: 1000
  512. });
  513. } else if (this.data.total === 0) {
  514. wx.showToast({
  515. title: '请选择商品数量',
  516. icon: 'error',
  517. duration: 2000
  518. });
  519. } else {
  520. const data = []
  521. this.data.couponList.forEach(v => {
  522. if (v.quantity > 0) {
  523. data.push({
  524. couponid: v.id,
  525. num: v.quantity,
  526. })
  527. }
  528. })
  529. // let fingerprint = ''
  530. // let sessionid = ''
  531. // // #ifndef MP-WEIXIN
  532. // fingerprint = window.fmOpt
  533. // sessionid = window.sessionId
  534. // // #endif
  535. Integralinfo.getOrder({
  536. fingerprint:'',
  537. list: data,
  538. mobile: getMobileCache(),
  539. tgid: this.data.tgid,
  540. sessionid:'',
  541. shopid: this.data.shopid
  542. }).then(res => {
  543. if (res.code === '0000') {
  544. this.codeSetInterval(60)
  545. this.setData({
  546. codeName: '60s后重新获取',
  547. paymentStatus: true,
  548. paymentBgStatus: true,
  549. active1code: '',
  550. active2code: '',
  551. active1obj:{
  552. orderId: res.data.orderId,
  553. order_no: res.data.order_no,
  554. step: res.data.step,
  555. date: Math.round(new Date().getTime() / 1000).toString(),
  556. mobile: getMobileCache()
  557. },
  558. })
  559. wx.setStorageSync('orderDetails', JSON.stringify(this.data.active1obj))
  560. if (res.data.step === 1) {
  561. this.setData({
  562. activeNum: 1,
  563. })
  564. } else if (res.data.step === 2) {
  565. this.setData({
  566. activeNum: 0,
  567. })
  568. }
  569. console.log(res.data.step,this.data.activeNum)
  570. // this.getPaySend()
  571. } else {
  572. console.log(res.message)
  573. console.log(this.data.integralNum,this.data.mobile,JSON.stringify(data))
  574. // log.error(`${res.data.message}`)
  575. // log.error(`${this.data.integralNum},${this.data.mobile},${JSON.stringify(data)}`)
  576. wx.showToast({
  577. icon: 'none',
  578. title: res.message
  579. })
  580. }
  581. }).catch(error=>{
  582. console.log('zhifu')
  583. console.log(error)
  584. wx.showToast({
  585. icon: 'none',
  586. title: error
  587. })
  588. })
  589. }
  590. },
  591. // 步骤按钮
  592. nextCodeClick() {
  593. console.log(this.data.activeNum,this.data.active2code)
  594. if (this.data.activeNum === 1 && this.data.active2code !== '') {
  595. // wx.showLoading({
  596. // title: '兑换中'
  597. // });
  598. // let fingerprint = ''
  599. // let sessionid = ''
  600. // // #ifndef MP-WEIXIN
  601. // fingerprint = window.fmOpt
  602. // sessionid = window.sessionId
  603. // #endif
  604. Integralinfo.getPayOnce({
  605. fingerprint: '',
  606. mobile: getMobileCache(),
  607. optCode: this.data.active2code,
  608. order_no: this.data.active1obj.order_no,
  609. orderId: this.data.active1obj.orderId,
  610. sessionid: '',
  611. shopid: this.data.shopid
  612. }).then(res => {
  613. if (res.code === '0000') {
  614. const obj = {
  615. mobile: this.data.mobile,
  616. channelid: this.data.channelid,
  617. shopid: this.data.shopid,
  618. storeid: this.data.storeid
  619. }
  620. this.data.integralNum -= this.data.total
  621. this.setData({
  622. integralNum: this.data.integralNum,
  623. total: 0,
  624. listStatus: false,
  625. listTrue: [],
  626. })
  627. this.data.couponList.forEach((v)=>{
  628. v.quantity = 0
  629. })
  630. this.setData({
  631. couponList: this.data.couponList,
  632. paymentStatus: false,
  633. paymentBgStatus: false,
  634. })
  635. wx.setStorageSync('orderDetails', null)
  636. wx.hideLoading();
  637. wx.navigateTo({
  638. url: '../integral/success?row=' + JSON.stringify(obj)
  639. })
  640. } else {
  641. wx.hideLoading();
  642. wx.showToast({
  643. icon: 'none',
  644. title: res.message
  645. })
  646. }
  647. }).catch(error => {
  648. let res = error.data;
  649. wx.showToast({
  650. icon: 'none',
  651. title: res.message
  652. })
  653. });
  654. } else if (this.data.activeNum === 0 && this.data.active1code !== '') {
  655. Integralinfo.getExchange({
  656. fingerprint: '',
  657. mobile: getMobileCache(),
  658. optCode: this.data.active1code,
  659. orderId: this.data.active1obj.orderId,
  660. order_no: this.data.active1obj.order_no,
  661. sessionid: '',
  662. shopid: this.data.shopid
  663. }).then(res => {
  664. if (res.code === '0000') {
  665. clearInterval(this.data.codeTime)
  666. this.setData({
  667. active2code: '',
  668. activeNum: this.activeNum++,
  669. codeName: '60s后重新获取',
  670. })
  671. this.codeSetInterval(60)
  672. } else {
  673. wx.showToast({
  674. icon: 'none',
  675. title: res.message
  676. })
  677. }
  678. }).catch(error => {
  679. let res = error.data;
  680. wx.showToast({
  681. icon: 'none',
  682. title: res.message
  683. })
  684. })
  685. } else {
  686. wx.showToast({
  687. icon: 'error',
  688. title: '请填写验证码'
  689. })
  690. }
  691. },
  692. // 短信定时器
  693. codeSetInterval(num) {
  694. console.log(num)
  695. let time = num
  696. this.data.codeTime = setInterval(() => {
  697. if (time <= 1) {
  698. this.setData({
  699. codeName: '重新获取验证码',
  700. })
  701. clearInterval(this.data.codeTime)
  702. } else {
  703. time--
  704. this.setData({
  705. codeName:`${time}s后重新获取`
  706. })
  707. }
  708. }, 1000)
  709. },
  710. getPaySend(){
  711. if (this.data.activeNum === 1) {
  712. console.log('发送短信')
  713. Integralinfo.getPaySend({
  714. order_no: this.data.active1obj.order_no,
  715. mobile: getMobileCache(),
  716. shopid: this.data.shopid,
  717. }).then(res => {
  718. if (res.code === '0000') {
  719. this.setData({
  720. codeName: '60s后重新获取',
  721. })
  722. this.codeSetInterval(60)
  723. } else {
  724. wx.showToast({
  725. icon: 'none',
  726. title: res.message
  727. })
  728. }
  729. }).catch(error=>{
  730. console.log('duanxin')
  731. console.log(error)
  732. })
  733. }
  734. },
  735. // 重新获取短信
  736. getCodeClick() {
  737. console.log(this.data.activeNum,this.data.codeName,this.data.active1obj.step)
  738. if ((this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') && this.data.active1obj.step === 1) {
  739. Integralinfo.getSendCmccSms({
  740. orderId: this.data.active1obj.orderId,
  741. mobile: getMobileCache(),
  742. shopid: this.data.shopid
  743. }).then(res => {
  744. if (res.code === '0000') {
  745. this.setData({
  746. codeName: '60s后重新获取',
  747. })
  748. this.codeSetInterval(60)
  749. const obj = this.data.active1obj
  750. obj.date = Math.round(new Date().getTime() / 1000).toString()
  751. wx.setStorageSync('orderDetails', JSON.stringify(obj))
  752. } else {
  753. wx.showToast({
  754. icon: 'none',
  755. title: res.message
  756. })
  757. }
  758. }).catch(error=>{
  759. console.log('chongxin')
  760. console.log(error)
  761. });
  762. } else {
  763. if (this.data.activeNum === 0 && this.data.codeName === '重新获取验证码') {
  764. Integralinfo.getSendCmccSms({
  765. orderId: this.data.active1obj.orderId,
  766. mobile: getMobileCache(),
  767. shopid: this.data.shopid
  768. }).then(res => {
  769. if (res.code === '0000') {
  770. this.codeName = '60s后重新获取'
  771. this.codeSetInterval(60)
  772. } else {
  773. wx.showToast({
  774. icon: 'none',
  775. title: res.message
  776. })
  777. }
  778. }).catch(error=>{
  779. console.log('chongxin')
  780. console.log(error)
  781. });
  782. } else if (this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') {
  783. console.log('短信')
  784. Integralinfo.getPaySend({
  785. order_no: this.data.active1obj.order_no,
  786. mobile: getMobileCache(),
  787. shopid: this.data.shopid,
  788. }).then(res => {
  789. if (res.code === '0000') {
  790. this.setData({
  791. codeName: '60s后重新获取',
  792. })
  793. this.codeSetInterval(60)
  794. } else {
  795. wx.showToast({
  796. icon: 'none',
  797. title: res.message
  798. })
  799. }
  800. }).catch(error=>{
  801. console.log('chongxin')
  802. console.log(error)
  803. });
  804. }
  805. }
  806. },
  807. toExchange(){
  808. const obj = {
  809. mobile: getMobileCache(),
  810. channelid: this.data.channelid,
  811. shopid: this.data.shopid,
  812. storeid: this.data.storeid
  813. }
  814. wx.navigateTo({
  815. url: '../integral/exchange?obj=' + JSON.stringify(obj)
  816. })
  817. }
  818. })