integral.js 28 KB

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