integral.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  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. if(getMobileCache() != ''){
  86. Integralinfo.getBalance({
  87. mobile: getMobileCache(),
  88. callbackUrl: '../integral/integral.wxml',
  89. fingerprint: '',
  90. sessionid: '',
  91. shopid: this.data.shopid,
  92. type: 'wx',
  93. }).then(arr => {
  94. if (arr.code === '0000') {
  95. var reg = /^(\d{3})\d{4}(\d{4})$/;
  96. this.setData({
  97. isLogin: getMobileCache() != '',
  98. phone: getMobileCache() == ''?'********':getMobileCache().replace(reg, "$1****$2"),
  99. setPhone: getMobileCache(),
  100. mobile: getMobileCache(),
  101. integralNum: arr.data,
  102. })
  103. // 获取优惠券列表
  104. this.getCouponList()
  105. }
  106. })
  107. } else {
  108. // 获取优惠券列表
  109. this.getCouponList()
  110. }
  111. },
  112. /**
  113. * 判断是否是iphone
  114. */
  115. isIphone() {
  116. let isIphone = false
  117. wx.getSystemInfo({
  118. success: function(res) {
  119. if (res.model.indexOf('iPhone') >= 0) {
  120. isIphone = true;
  121. }
  122. }
  123. })
  124. return isIphone
  125. },
  126. /**
  127. * 生命周期函数--监听页面隐藏
  128. */
  129. onHide: function () {
  130. },
  131. /**
  132. * 生命周期函数--监听页面卸载
  133. */
  134. onUnload: function () {
  135. },
  136. /**
  137. * 页面相关事件处理函数--监听用户下拉动作
  138. */
  139. onPullDownRefresh: function () {
  140. },
  141. /**
  142. * 页面上拉触底事件的处理函数
  143. */
  144. onReachBottom: function () {
  145. },
  146. /**
  147. * 用户点击右上角分享
  148. */
  149. onShareAppMessage: function () {
  150. },
  151. getBannerList: function() {
  152. Integralinfo.getBannerList({
  153. channelid: this.data.channelid,
  154. shopid: this.data.shopid,
  155. storeid: this.data.storeid
  156. }).then(res => {
  157. console.log(res.data)
  158. this.setData({
  159. bannerList: res.data
  160. })
  161. }).catch(err => {
  162. console.log(err)
  163. })
  164. },
  165. getCouponList: function() {
  166. Integralinfo.getList({
  167. channelid: this.data.channelid,
  168. shopid: this.data.shopid,
  169. storeid: this.data.storeid
  170. }).then(res => {
  171. this.couponListView(res.data)
  172. this.data.lock = false
  173. }).catch(_ => {
  174. console.log(_)
  175. this.data.lock = false
  176. })
  177. },
  178. couponListView: function(data) {
  179. if (!Array.isArray(data) || data.length == 0) {
  180. console.log("优惠券列表数据为空");
  181. }
  182. data.forEach((v) => {
  183. v.quantity = 0
  184. v.integral = v.price * v.ratio
  185. })
  186. if (this.data.mobile != '********') {
  187. let num = this.data.integralNum > 20000 ? 19999 : this.data.integralNum
  188. const arr = []
  189. this.setData({
  190. total: 0,
  191. })
  192. for (let i = 0; i < data.length; i++) {
  193. data[i].quantity = parseInt(num / data[i].integral)
  194. if (data[i].quantity > 0) {
  195. num -= (data[i].quantity * data[i].price) * data[i].ratio
  196. this.data.total += (data[i].quantity * data[i].price) * data[i].ratio
  197. this.setData({
  198. total:this.data.total
  199. })
  200. arr.push(data[i])
  201. data.splice(i, 1)
  202. i--
  203. }
  204. }
  205. this.setData({
  206. couponList: [...arr, ...data]
  207. })
  208. } else {
  209. this.setData({
  210. couponList: data
  211. })
  212. }
  213. console.log(this.data.total)
  214. },
  215. // 点击标识点触发
  216. detailsClick(row) {
  217. this.hideModal();
  218. this.row = row.currentTarget.dataset.info
  219. console.log(this.row)
  220. if (this.row.detail_type === 0) {
  221. this.row.detailArr = this.row.detail.split('\n')
  222. } else {
  223. this.row.detailArr = row.detail
  224. }
  225. this.setData({
  226. integralIngo: this.row,
  227. })
  228. console.log(this.data.integralIngo)
  229. setTimeout(() => {
  230. this.showDodal();
  231. }, 100)
  232. },
  233. showDodal() {
  234. var that = this;
  235. // 显示遮罩层
  236. var animation = wx.createAnimation({
  237. duration: 150,
  238. timingFunction: "linear",
  239. delay: 0
  240. })
  241. this.setData({
  242. bgStatus: true,
  243. bodyHidden: false
  244. })
  245. that.animation = animation
  246. animation.translateY(-500).step()
  247. that.setData({
  248. animationData: animation.export()
  249. })
  250. },
  251. //隐藏对话框
  252. hideModal() {
  253. var that = this;
  254. console.log(that.data)
  255. // 隐藏遮罩层
  256. var animation = wx.createAnimation({
  257. duration: 150,
  258. timingFunction: "linear",
  259. delay: 0
  260. })
  261. this.setData({
  262. bodyHidden: true,
  263. bgStatus: false,
  264. scorePhone: false,
  265. })
  266. that.animation = animation
  267. animation.translateY(0).step()
  268. that.setData({
  269. animationData: animation.export()
  270. })
  271. },
  272. /**授权手机号 */
  273. getPhoneNumber(e) {
  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(this.data.setPhone)
  311. if (!(/^1[3456789]\d{9}$/.test(this.data.setPhone))) {
  312. wx.showToast({
  313. title: '填写正确手机号',
  314. icon: 'error',
  315. duration: 2000
  316. });
  317. } else if (this.data.setPhone != '') {
  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.data.activeNum = 1
  373. } else if (data.step === 2) {
  374. this.data.activeNum = 0
  375. }
  376. }
  377. }
  378. } else {
  379. this.setData({
  380. loading: true,
  381. bgStatus: true
  382. })
  383. setTimeout(() => {
  384. // #ifdef H5
  385. window.location.href = arr.message;
  386. // #endif
  387. // #ifdef MP-WEIXIN
  388. const version = wx.getSystemInfoSync().SDKVersion
  389. if (this.compareVersion(version, '2.20.1') >= 0) {
  390. wx.openEmbeddedMiniProgram({
  391. appId: arr.data.appId,
  392. path: arr.data.path,
  393. extraData: arr.data.extraData,
  394. success(res) {
  395. // 打开成功
  396. },
  397. fail() {}
  398. })
  399. } else {
  400. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  401. wx.navigateToMiniProgram({
  402. appId: arr.data.appId,
  403. path: arr.data.path,
  404. extraData: arr.data.extraData,
  405. success(res) {
  406. // 打开成功
  407. },
  408. fail() {
  409. }
  410. })
  411. }
  412. // #endif
  413. this.hideModal()
  414. this.loading = false
  415. }, 4000)
  416. }
  417. })
  418. }
  419. },
  420. // 商品数量减少按钮
  421. reduceClick(e) {
  422. console.log(e.currentTarget.dataset.index)
  423. let index = e.currentTarget.dataset.index
  424. this.data.couponList[index].quantity--
  425. this.data.total -= parseInt(this.data.couponList[index].integral)
  426. this.setData({
  427. total: this.data.total,
  428. couponList: this.data.couponList
  429. })
  430. },
  431. // 商品数量添加按钮
  432. addClick(e) {
  433. let index = e.currentTarget.dataset.index
  434. if (this.data.phone !== '********') {
  435. if (this.data.total + parseInt(this.data.couponList[index].integral) > 20000) {
  436. wx.showToast({
  437. title: '单笔限额两万分',
  438. icon: 'error',
  439. duration: 2000
  440. });
  441. } else if ((this.data.integralNum - this.data.total) >= this.data.couponList[index].integral) {
  442. this.data.couponList[index].quantity++
  443. this.data.total += parseInt(this.data.couponList[index].integral)
  444. this.setData({
  445. total: this.data.total,
  446. couponList:this.data.couponList
  447. })
  448. } else {
  449. wx.showToast({
  450. title: '积分不足',
  451. icon: 'error',
  452. duration: 2000
  453. });
  454. }
  455. } else {
  456. wx.showToast({
  457. title: '先查询移动积分',
  458. icon: 'error',
  459. duration: 1000
  460. });
  461. setTimeout(() => {
  462. this.scoreClick()
  463. }, 1000)
  464. }
  465. },
  466. /** 刷新 */
  467. shuaxinClick() {
  468. Integralinfo.getBalance({
  469. mobile: getMobileCache(),
  470. callbackUrl: '../integral/integral.wxml',
  471. fingerprint: '',
  472. sessionid: '',
  473. shopid: this.data.shopid,
  474. type: 'wx',
  475. }).then(arr => {
  476. if (arr.code === '0000') {
  477. wx.hideLoading();
  478. wx.showToast({
  479. title: '查询成功!',
  480. icon: 'success',
  481. duration: 1000
  482. });
  483. var reg = /^(\d{3})\d{4}(\d{4})$/;
  484. this.setData({
  485. integralNum: arr.data,
  486. setPhone: getMobileCache(),
  487. phone: getMobileCache().replace(reg, "$1****$2"),
  488. })
  489. }
  490. })
  491. },
  492. // 支付按钮
  493. paymentClick() {
  494. console.log(this.data.mobile)
  495. if (this.data.mobile === '********') {
  496. setTimeout(() => {
  497. this.scoreClick()
  498. }, 1000)
  499. wx.showToast({
  500. title: '先查询移动积分',
  501. icon: 'error',
  502. duration: 1000
  503. });
  504. } else if (this.data.total === 0) {
  505. wx.showToast({
  506. title: '请选择商品数量',
  507. icon: 'error',
  508. duration: 2000
  509. });
  510. } else {
  511. const data = []
  512. this.data.couponList.forEach(v => {
  513. if (v.quantity > 0) {
  514. data.push({
  515. couponid: v.id,
  516. num: v.quantity,
  517. })
  518. }
  519. })
  520. // let fingerprint = ''
  521. // let sessionid = ''
  522. // // #ifndef MP-WEIXIN
  523. // fingerprint = window.fmOpt
  524. // sessionid = window.sessionId
  525. // // #endif
  526. Integralinfo.getOrder({
  527. fingerprint:'',
  528. list: data,
  529. mobile: getMobileCache(),
  530. tgid: this.data.tgid,
  531. sessionid:'',
  532. shopid: this.data.shopid
  533. }).then(res => {
  534. if (res.code === '0000') {
  535. this.codeSetInterval(60)
  536. this.setData({
  537. codeName: '60s后重新获取',
  538. paymentStatus: true,
  539. paymentBgStatus: true,
  540. active1code: '',
  541. active2code: '',
  542. active1obj:{
  543. orderId: res.data.orderId,
  544. order_no: res.data.order_no,
  545. step: res.data.step,
  546. date: Math.round(new Date().getTime() / 1000).toString(),
  547. mobile: getMobileCache()
  548. },
  549. })
  550. wx.setStorageSync('orderDetails', JSON.stringify(this.data.active1obj))
  551. if (res.data.step === 1) {
  552. this.setData({
  553. activeNum: 1,
  554. })
  555. } else if (res.data.step === 2) {
  556. this.setData({
  557. activeNum: 0,
  558. })
  559. }
  560. // this.getPaySend()
  561. } else {
  562. console.log(res.data.message)
  563. console.log(this.data.integralNum,this.data.mobile,JSON.stringify(data))
  564. // log.error(`${res.data.message}`)
  565. // log.error(`${this.data.integralNum},${this.data.mobile},${JSON.stringify(data)}`)
  566. this.setData({
  567. showToastObj: {
  568. icon: 'iconSueecss',
  569. title: res.data.message,
  570. status: true
  571. }
  572. })
  573. setTimeout(() => {
  574. this.setData({
  575. showToastObj: {
  576. icon: 'iconSueecss',
  577. title: res.data.message,
  578. status: false
  579. }
  580. })
  581. }, 2500)
  582. }
  583. })
  584. }
  585. },
  586. // 步骤按钮
  587. nextCodeClick() {
  588. console.log(this.data.activeNum,this.data.active2code)
  589. if (this.data.activeNum === 1 && this.data.active2code !== '') {
  590. // wx.showLoading({
  591. // title: '兑换中'
  592. // });
  593. // let fingerprint = ''
  594. // let sessionid = ''
  595. // // #ifndef MP-WEIXIN
  596. // fingerprint = window.fmOpt
  597. // sessionid = window.sessionId
  598. // #endif
  599. Integralinfo.getPayOnce({
  600. fingerprint: '',
  601. mobile: getMobileCache(),
  602. optCode: this.data.active2code,
  603. order_no: this.data.active1obj.order_no,
  604. orderId: this.data.active1obj.orderId,
  605. sessionid: '',
  606. shopid: this.data.shopid
  607. }).then(res => {
  608. if (res.code === '0000') {
  609. const obj = {
  610. mobile: this.data.mobile,
  611. channelid: this.data.channelid,
  612. shopid: this.data.shopid,
  613. storeid: this.data.storeid
  614. }
  615. this.data.integralNum -= this.data.total
  616. this.setData({
  617. integralNum: this.data.integralNum,
  618. total: 0,
  619. listStatus: false,
  620. listTrue: [],
  621. })
  622. this.data.couponList.forEach((v)=>{
  623. v.quantity = 0
  624. })
  625. this.setData({
  626. couponList: this.data.couponList,
  627. paymentStatus: false,
  628. paymentBgStatus: false,
  629. })
  630. wx.setStorageSync('orderDetails', null)
  631. wx.hideLoading();
  632. wx.navigateTo({
  633. url: '../integral/success?row=' + JSON.stringify(obj)
  634. })
  635. } else {
  636. wx.hideLoading();
  637. this.setData({
  638. showToastObj: {
  639. icon: 'iconSueecss',
  640. title: res.message,
  641. status: true
  642. }
  643. })
  644. setTimeout(() => {
  645. this.setData({
  646. showToastObj: {
  647. icon: 'iconSueecss',
  648. title: res.message,
  649. status: false
  650. }
  651. })
  652. }, 2500)
  653. }
  654. });
  655. } else if (this.data.activeNum === 0 && this.data.active1code !== '') {
  656. Integralinfo.getPayOnce({
  657. fingerprint: '',
  658. mobile: getMobileCache(),
  659. optCode: this.data.active1code,
  660. orderId: this.data.active1obj.orderId,
  661. order_no: this.data.active1obj.order_no,
  662. sessionid: '',
  663. shopid: this.data.shopid
  664. }).then(res => {
  665. if (res.code === '0000') {
  666. clearInterval(this.data.codeTime)
  667. this.setData({
  668. active2code: '',
  669. activeNum: this.activeNum++,
  670. codeName: '60s后重新获取',
  671. })
  672. this.codeSetInterval(60)
  673. } else {
  674. this.setData({
  675. showToastObj: {
  676. icon: 'iconSueecss',
  677. title: res.message,
  678. status: true
  679. }
  680. })
  681. setTimeout(() => {
  682. this.setData({
  683. showToastObj: {
  684. icon: 'iconSueecss',
  685. title: res.message,
  686. status: false
  687. }
  688. })
  689. }, 2500)
  690. }
  691. })
  692. } else {
  693. wx.showToast({
  694. icon: 'error',
  695. title: '请填写验证码'
  696. })
  697. }
  698. },
  699. // 短信定时器
  700. codeSetInterval(num) {
  701. console.log(num)
  702. let time = num
  703. this.data.codeTime = setInterval(() => {
  704. if (time <= 1) {
  705. this.setData({
  706. codeName: '重新获取验证码',
  707. })
  708. clearInterval(this.data.codeTime)
  709. } else {
  710. time--
  711. this.setData({
  712. codeName:`${time}s后重新获取`
  713. })
  714. }
  715. }, 1000)
  716. },
  717. getPaySend(){
  718. if (this.data.activeNum === 1) {
  719. console.log('发送短信')
  720. Integralinfo.getPaySend({
  721. order_no: this.data.active1obj.order_no,
  722. mobile: getMobileCache(),
  723. shopid: this.data.shopid,
  724. }).then(res => {
  725. if (res.code === '0000') {
  726. this.setData({
  727. codeName: '60s后重新获取',
  728. })
  729. this.codeSetInterval(60)
  730. } else {
  731. this.setData({
  732. showToastObj: {
  733. icon: 'iconSueecss',
  734. title: res.message,
  735. status: true
  736. }
  737. })
  738. setTimeout(() => {
  739. this.setData({
  740. showToastObj: {
  741. icon: 'iconSueecss',
  742. title: res.message,
  743. status: false
  744. }
  745. })
  746. }, 2500)
  747. }
  748. })
  749. }
  750. },
  751. // 重新获取短信
  752. getCodeClick() {
  753. console.log(this.data.activeNum,this.data.codeName,this.data.active1obj.step)
  754. if ((this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') && this.data.active1obj.step === 1) {
  755. Integralinfo.getSendCmccSms({
  756. orderId: this.data.active1obj.orderId,
  757. mobile: getMobileCache(),
  758. shopid: this.data.shopid
  759. }).then(res => {
  760. if (res.code === '0000') {
  761. this.setData({
  762. codeName: '60s后重新获取',
  763. })
  764. this.codeSetInterval(60)
  765. const obj = this.data.active1obj
  766. obj.date = Math.round(new Date().getTime() / 1000).toString()
  767. wx.setStorageSync('orderDetails', JSON.stringify(obj))
  768. } else {
  769. this.setData({
  770. showToastObj: {
  771. icon: 'iconSueecss',
  772. title: res.message,
  773. status: true
  774. }
  775. })
  776. setTimeout(() => {
  777. this.setData({
  778. showToastObj: {
  779. icon: 'iconSueecss',
  780. title: res.message,
  781. status: false
  782. }
  783. })
  784. }, 2500)
  785. }
  786. });
  787. } else {
  788. if (this.data.activeNum === 0 && this.data.codeName === '重新获取验证码') {
  789. Integralinfo.getSendCmccSms({
  790. orderId: this.data.active1obj.orderId,
  791. mobile: getMobileCache(),
  792. shopid: this.data.shopid
  793. }).then(res => {
  794. if (res.code === '0000') {
  795. this.codeName = '60s后重新获取'
  796. this.codeSetInterval(60)
  797. } else {
  798. this.setData({
  799. showToastObj: {
  800. icon: 'iconSueecss',
  801. title: res.message,
  802. status: true
  803. }
  804. })
  805. setTimeout(() => {
  806. this.setData({
  807. showToastObj: {
  808. icon: 'iconSueecss',
  809. title: res.message,
  810. status: false
  811. }
  812. })
  813. }, 2500)
  814. }
  815. });
  816. } else if (this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') {
  817. console.log('短信')
  818. Integralinfo.getPaySend({
  819. order_no: this.data.active1obj.order_no,
  820. mobile: getMobileCache(),
  821. shopid: this.data.shopid,
  822. }).then(res => {
  823. if (res.code === '0000') {
  824. this.setData({
  825. codeName: '60s后重新获取',
  826. })
  827. this.codeSetInterval(60)
  828. } else {
  829. this.setData({
  830. showToastObj: {
  831. icon: 'iconSueecss',
  832. title: res.message,
  833. status: true
  834. }
  835. })
  836. setTimeout(() => {
  837. this.setData({
  838. showToastObj: {
  839. icon: 'iconSueecss',
  840. title: res.message,
  841. status: false
  842. }
  843. })
  844. }, 2500)
  845. }
  846. });
  847. }
  848. }
  849. },
  850. toExchange(){
  851. const obj = {
  852. mobile: getMobileCache(),
  853. channelid: this.data.channelid,
  854. shopid: this.data.shopid,
  855. storeid: this.data.storeid
  856. }
  857. wx.navigateTo({
  858. url: '../integral/exchange?obj=' + JSON.stringify(obj)
  859. })
  860. }
  861. })