integral.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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. // paymenHideModal() {
  273. // var that = this;
  274. // console.log(that.data)
  275. // this.setData({
  276. // bodyHidden: true,
  277. // paymentBgStatus: false,
  278. // paymentStatus: false,
  279. // })
  280. // },
  281. /**授权手机号 */
  282. getPhoneNumber(e) {
  283. let that = this;
  284. getPhoneNumberSync(e, async () => {
  285. console.log(e)
  286. if (getMobileCache() == '') {
  287. wx.showToast({
  288. icon:'error',
  289. title:'先查询移动积分'
  290. })
  291. setTimeout(()=>{
  292. that.data.setPhone = ''
  293. that.scoreClick()
  294. wx.hideLoading()
  295. },500)
  296. } else {
  297. var reg = /^(\d{3})\d{4}(\d{4})$/;
  298. this.setData({
  299. isLogin: true,
  300. setPhone: getMobileCache(),
  301. mobile: getMobileCache(),
  302. phone: getMobileCache().replace(reg, "$1****$2")
  303. })
  304. // console.log(this.data.setPhone)
  305. // console.log(this.data.mobile)
  306. // console.log(this.data.phone)
  307. this.getphoneClick()
  308. }
  309. })
  310. },
  311. // 查询积分
  312. scoreClick() {
  313. this.setData({
  314. bgStatus: true,
  315. scorePhone: true,
  316. })
  317. },
  318. // 查询积分
  319. getphoneClick() {
  320. console.log(getMobileCache())
  321. if (!(/^1[3456789]\d{9}$/.test(getMobileCache()))) {
  322. wx.showToast({
  323. title: '填写正确手机号',
  324. icon: 'error',
  325. duration: 2000
  326. });
  327. } else if (getMobileCache() != '') {
  328. // wx.showLoading({
  329. // title: '加载中'
  330. // });
  331. Integralinfo.getBalance({
  332. mobile: getMobileCache(),
  333. callbackUrl: '../integral/integral.wxml',
  334. fingerprint: '',
  335. sessionid: '',
  336. shopid: this.data.shopid,
  337. type: 'wx',
  338. }).then(arr => {
  339. console.log(arr)
  340. wx.hideLoading();
  341. if (arr.code === '0000') {
  342. var reg = /^(\d{3})\d{4}(\d{4})$/;
  343. this.setData({
  344. integralNum: arr.data,
  345. setPhone: getMobileCache(),
  346. phone: getMobileCache().replace(reg, "$1****$2"),
  347. })
  348. // this.data.integralNum = arr.data
  349. // var reg = /^(\d{3})\d{4}(\d{4})$/;
  350. // this.data.mobile = this.data.setPhone
  351. // this.data.setPhone = this.data.setPhone.replace(reg, "$1****$2");
  352. let response = {
  353. points: arr.data,
  354. outTokenId: this.data.setPhone + '_out'
  355. }
  356. // App.globalData.AppShow = response
  357. this.hideModal()
  358. this.getCouponList()
  359. wx.pageScrollTo({
  360. scrollTop: 0
  361. });
  362. let dateNum = Math.round(new Date().getTime() / 1000).toString()
  363. if (wx.getStorageSync('orderDetails') != '' && this.data.mobile === JSON.parse(wx
  364. .getStorageSync('orderDetails')).mobile) {
  365. if (dateNum - JSON.parse(wx.getStorageSync('orderDetails')).date <= 120) {
  366. const data = JSON.parse(wx.getStorageSync('orderDetails'))
  367. if (dateNum - data.date < 60) {
  368. let time = dateNum - data.date
  369. this.data.codeName = 60 - time + 's后重新获取'
  370. this.codeSetInterval(60 - time)
  371. } else {
  372. this.data.codeName = '重新获取验证码'
  373. }
  374. this.setData({
  375. paymentStatus: true,
  376. paymentBgStatus: true,
  377. active1code: '',
  378. active2code: '',
  379. active1obj: data,
  380. })
  381. if (data.step === 1) {
  382. this.setData({
  383. activeNum: 1,
  384. })
  385. } else if (data.step === 2) {
  386. this.setData({
  387. activeNum: 0,
  388. })
  389. }
  390. }
  391. }
  392. } else {
  393. this.setData({
  394. loading: true,
  395. bgStatus: true
  396. })
  397. setTimeout(() => {
  398. // #ifdef H5
  399. window.location.href = arr.message;
  400. // #endif
  401. // #ifdef MP-WEIXIN
  402. const version = wx.getSystemInfoSync().SDKVersion
  403. if (this.compareVersion(version, '2.20.1') >= 0) {
  404. wx.openEmbeddedMiniProgram({
  405. appId: arr.data.appId,
  406. path: arr.data.path,
  407. extraData: arr.data.extraData,
  408. success(res) {
  409. // 打开成功
  410. },
  411. fail() {}
  412. })
  413. } else {
  414. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  415. wx.navigateToMiniProgram({
  416. appId: arr.data.appId,
  417. path: arr.data.path,
  418. extraData: arr.data.extraData,
  419. success(res) {
  420. // 打开成功
  421. },
  422. fail() {
  423. }
  424. })
  425. }
  426. // #endif
  427. this.hideModal()
  428. this.loading = false
  429. }, 4000)
  430. }
  431. }).catch(error => {
  432. console.log(error)
  433. })
  434. }
  435. },
  436. // 商品数量减少按钮
  437. reduceClick(e) {
  438. console.log(e.currentTarget.dataset.index)
  439. let index = e.currentTarget.dataset.index
  440. this.data.couponList[index].quantity--
  441. this.data.total -= parseInt(this.data.couponList[index].integral)
  442. this.setData({
  443. total: this.data.total,
  444. couponList: this.data.couponList
  445. })
  446. },
  447. // 商品数量添加按钮
  448. addClick(e) {
  449. let index = e.currentTarget.dataset.index
  450. if (this.data.phone !== '********') {
  451. if (this.data.total + parseInt(this.data.couponList[index].integral) > 20000) {
  452. wx.showToast({
  453. title: '单笔限额两万分',
  454. icon: 'error',
  455. duration: 2000
  456. });
  457. } else if ((this.data.integralNum - this.data.total) >= this.data.couponList[index].integral) {
  458. this.data.couponList[index].quantity++
  459. this.data.total += parseInt(this.data.couponList[index].integral)
  460. this.setData({
  461. total: this.data.total,
  462. couponList:this.data.couponList
  463. })
  464. } else {
  465. wx.showToast({
  466. title: '积分不足',
  467. icon: 'error',
  468. duration: 2000
  469. });
  470. }
  471. } else {
  472. wx.showToast({
  473. title: '先查询移动积分',
  474. icon: 'error',
  475. duration: 1000
  476. });
  477. setTimeout(() => {
  478. this.scoreClick()
  479. }, 1000)
  480. }
  481. },
  482. /** 刷新 */
  483. shuaxinClick() {
  484. Integralinfo.getBalance({
  485. mobile: getMobileCache(),
  486. callbackUrl: '../integral/integral.wxml',
  487. fingerprint: '',
  488. sessionid: '',
  489. shopid: this.data.shopid,
  490. type: 'wx',
  491. }).then(arr => {
  492. if (arr.code === '0000') {
  493. wx.hideLoading();
  494. wx.showToast({
  495. title: '查询成功!',
  496. icon: 'success',
  497. duration: 1000
  498. });
  499. var reg = /^(\d{3})\d{4}(\d{4})$/;
  500. this.setData({
  501. integralNum: arr.data,
  502. setPhone: getMobileCache(),
  503. phone: getMobileCache().replace(reg, "$1****$2"),
  504. })
  505. }
  506. }).catch(error=>{
  507. console.log(222222)
  508. console.log(error)
  509. })
  510. },
  511. // 支付按钮
  512. paymentClick() {
  513. console.log(this.data.mobile)
  514. if (this.data.mobile === '********') {
  515. setTimeout(() => {
  516. this.scoreClick()
  517. }, 1000)
  518. wx.showToast({
  519. title: '先查询移动积分',
  520. icon: 'error',
  521. duration: 1000
  522. });
  523. } else if (this.data.total === 0) {
  524. wx.showToast({
  525. title: '请选择商品数量',
  526. icon: 'error',
  527. duration: 2000
  528. });
  529. } else {
  530. const data = []
  531. this.data.couponList.forEach(v => {
  532. if (v.quantity > 0) {
  533. data.push({
  534. couponid: v.id,
  535. num: v.quantity,
  536. })
  537. }
  538. })
  539. // let fingerprint = ''
  540. // let sessionid = ''
  541. // // #ifndef MP-WEIXIN
  542. // fingerprint = window.fmOpt
  543. // sessionid = window.sessionId
  544. // // #endif
  545. Integralinfo.getOrder({
  546. fingerprint:'',
  547. list: data,
  548. mobile: getMobileCache(),
  549. tgid: this.data.tgid,
  550. sessionid:'',
  551. shopid: this.data.shopid
  552. }).then(res => {
  553. if (res.code === '0000') {
  554. this.codeSetInterval(60)
  555. this.setData({
  556. codeName: '60s后重新获取',
  557. paymentStatus: true,
  558. paymentBgStatus: true,
  559. active1code: '',
  560. active2code: '',
  561. active1obj:{
  562. orderId: res.data.orderId,
  563. order_no: res.data.order_no,
  564. step: res.data.step,
  565. date: Math.round(new Date().getTime() / 1000).toString(),
  566. mobile: getMobileCache()
  567. },
  568. })
  569. wx.setStorageSync('orderDetails', JSON.stringify(this.data.active1obj))
  570. if (res.data.step === 1) {
  571. this.setData({
  572. activeNum: 1,
  573. })
  574. } else if (res.data.step === 2) {
  575. this.setData({
  576. activeNum: 0,
  577. })
  578. }
  579. console.log(res.data.step,this.data.activeNum)
  580. // this.getPaySend()
  581. } else {
  582. console.log(res.message)
  583. console.log(this.data.integralNum,this.data.mobile,JSON.stringify(data))
  584. // log.error(`${res.data.message}`)
  585. // log.error(`${this.data.integralNum},${this.data.mobile},${JSON.stringify(data)}`)
  586. wx.showToast({
  587. icon: 'none',
  588. title: res.message
  589. })
  590. }
  591. }).catch(error=>{
  592. console.log('zhifu')
  593. console.log(error)
  594. wx.showToast({
  595. icon: 'none',
  596. title: '请一分钟后再选择'
  597. })
  598. })
  599. }
  600. },
  601. // 步骤按钮
  602. nextCodeClick() {
  603. console.log(this.data.activeNum,this.data.active2code)
  604. if (this.data.activeNum === 1 && this.data.active2code !== '') {
  605. // wx.showLoading({
  606. // title: '兑换中'
  607. // });
  608. // let fingerprint = ''
  609. // let sessionid = ''
  610. // // #ifndef MP-WEIXIN
  611. // fingerprint = window.fmOpt
  612. // sessionid = window.sessionId
  613. // #endif
  614. Integralinfo.getPayOnce({
  615. fingerprint: '',
  616. mobile: getMobileCache(),
  617. optCode: this.data.active2code,
  618. order_no: this.data.active1obj.order_no,
  619. orderId: this.data.active1obj.orderId,
  620. sessionid: '',
  621. shopid: this.data.shopid
  622. }).then(res => {
  623. if (res.code === '0000') {
  624. const obj = {
  625. mobile: this.data.mobile,
  626. channelid: this.data.channelid,
  627. shopid: this.data.shopid,
  628. storeid: this.data.storeid
  629. }
  630. this.data.integralNum -= this.data.total
  631. this.setData({
  632. integralNum: this.data.integralNum,
  633. total: 0,
  634. listStatus: false,
  635. listTrue: [],
  636. })
  637. this.data.couponList.forEach((v)=>{
  638. v.quantity = 0
  639. })
  640. this.setData({
  641. couponList: this.data.couponList,
  642. paymentStatus: false,
  643. paymentBgStatus: false,
  644. })
  645. wx.setStorageSync('orderDetails', null)
  646. wx.hideLoading();
  647. wx.navigateTo({
  648. url: '../integral/success?row=' + JSON.stringify(obj)
  649. })
  650. } else {
  651. wx.hideLoading();
  652. wx.showToast({
  653. icon: 'none',
  654. title: res.message
  655. })
  656. }
  657. }).catch(error => {
  658. let res = error.data;
  659. wx.showToast({
  660. icon: 'none',
  661. title: res.message
  662. })
  663. });
  664. } else if (this.data.activeNum === 0 && this.data.active1code !== '') {
  665. Integralinfo.getExchange({
  666. fingerprint: '',
  667. mobile: getMobileCache(),
  668. optCode: this.data.active1code,
  669. orderId: this.data.active1obj.orderId,
  670. order_no: this.data.active1obj.order_no,
  671. sessionid: '',
  672. shopid: this.data.shopid
  673. }).then(res => {
  674. if (res.code === '0000') {
  675. clearInterval(this.data.codeTime)
  676. this.setData({
  677. active2code: '',
  678. activeNum: this.activeNum++,
  679. codeName: '60s后重新获取',
  680. })
  681. this.codeSetInterval(60)
  682. } else {
  683. wx.showToast({
  684. icon: 'none',
  685. title: res.message
  686. })
  687. }
  688. }).catch(error => {
  689. let res = error.data;
  690. wx.showToast({
  691. icon: 'none',
  692. title: res.message
  693. })
  694. })
  695. } else {
  696. wx.showToast({
  697. icon: 'error',
  698. title: '请填写验证码'
  699. })
  700. }
  701. },
  702. // 短信定时器
  703. codeSetInterval(num) {
  704. console.log(num)
  705. let time = num
  706. this.data.codeTime = setInterval(() => {
  707. if (time <= 1) {
  708. this.setData({
  709. codeName: '重新获取验证码',
  710. })
  711. clearInterval(this.data.codeTime)
  712. } else {
  713. time--
  714. this.setData({
  715. codeName:`${time}s后重新获取`
  716. })
  717. }
  718. }, 1000)
  719. },
  720. getPaySend(){
  721. if (this.data.activeNum === 1) {
  722. console.log('发送短信')
  723. Integralinfo.getPaySend({
  724. order_no: this.data.active1obj.order_no,
  725. mobile: getMobileCache(),
  726. shopid: this.data.shopid,
  727. }).then(res => {
  728. if (res.code === '0000') {
  729. this.setData({
  730. codeName: '60s后重新获取',
  731. })
  732. this.codeSetInterval(60)
  733. } else {
  734. wx.showToast({
  735. icon: 'none',
  736. title: res.message
  737. })
  738. }
  739. }).catch(error=>{
  740. console.log('duanxin')
  741. console.log(error)
  742. })
  743. }
  744. },
  745. // 重新获取短信
  746. getCodeClick() {
  747. console.log(this.data.activeNum,this.data.codeName,this.data.active1obj.step)
  748. if ((this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') && this.data.active1obj.step === 1) {
  749. Integralinfo.getSendCmccSms({
  750. orderId: this.data.active1obj.orderId,
  751. mobile: getMobileCache(),
  752. shopid: this.data.shopid
  753. }).then(res => {
  754. if (res.code === '0000') {
  755. this.setData({
  756. codeName: '60s后重新获取',
  757. })
  758. this.codeSetInterval(60)
  759. const obj = this.data.active1obj
  760. obj.date = Math.round(new Date().getTime() / 1000).toString()
  761. wx.setStorageSync('orderDetails', JSON.stringify(obj))
  762. } else {
  763. wx.showToast({
  764. icon: 'none',
  765. title: res.message
  766. })
  767. }
  768. }).catch(error=>{
  769. console.log('chongxin')
  770. console.log(error)
  771. });
  772. } else {
  773. if (this.data.activeNum === 0 && this.data.codeName === '重新获取验证码') {
  774. Integralinfo.getSendCmccSms({
  775. orderId: this.data.active1obj.orderId,
  776. mobile: getMobileCache(),
  777. shopid: this.data.shopid
  778. }).then(res => {
  779. if (res.code === '0000') {
  780. this.codeName = '60s后重新获取'
  781. this.codeSetInterval(60)
  782. } else {
  783. wx.showToast({
  784. icon: 'none',
  785. title: res.message
  786. })
  787. }
  788. }).catch(error=>{
  789. console.log('chongxin')
  790. console.log(error)
  791. });
  792. } else if (this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') {
  793. console.log('短信')
  794. Integralinfo.getPaySend({
  795. order_no: this.data.active1obj.order_no,
  796. mobile: getMobileCache(),
  797. shopid: this.data.shopid,
  798. }).then(res => {
  799. if (res.code === '0000') {
  800. this.setData({
  801. codeName: '60s后重新获取',
  802. })
  803. this.codeSetInterval(60)
  804. } else {
  805. wx.showToast({
  806. icon: 'none',
  807. title: res.message
  808. })
  809. }
  810. }).catch(error=>{
  811. console.log('chongxin')
  812. console.log(error)
  813. });
  814. }
  815. }
  816. },
  817. toExchange(){
  818. const obj = {
  819. mobile: getMobileCache(),
  820. channelid: this.data.channelid,
  821. shopid: this.data.shopid,
  822. storeid: this.data.storeid
  823. }
  824. wx.navigateTo({
  825. url: '../integral/exchange?obj=' + JSON.stringify(obj)
  826. })
  827. }
  828. })