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