integral.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  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. couponList: this.data.couponList,
  604. paymentStatus: false,
  605. paymentBgStatus: false,
  606. })
  607. wx.setStorageSync('orderDetails', null)
  608. wx.hideLoading();
  609. wx.navigateTo({
  610. url: '../success/success?row=' + JSON.stringify(obj)
  611. })
  612. } else {
  613. wx.hideLoading();
  614. this.setData({
  615. showToastObj: {
  616. icon: 'iconSueecss',
  617. title: res.message,
  618. status: true
  619. }
  620. })
  621. setTimeout(() => {
  622. this.setData({
  623. showToastObj: {
  624. icon: 'iconSueecss',
  625. title: res.message,
  626. status: false
  627. }
  628. })
  629. }, 2500)
  630. }
  631. });
  632. } else if (this.data.activeNum === 0 && this.data.active1code !== '') {
  633. Integralinfo.getPayOnce({
  634. fingerprint: '',
  635. mobile: this.data.mobile,
  636. optCode: this.data.active1code,
  637. orderId: this.data.active1obj.orderId,
  638. order_no: this.data.active1obj.order_no,
  639. sessionid: '',
  640. shopid: this.data.shopid
  641. }).then(res => {
  642. if (res.code === '0000') {
  643. clearInterval(this.data.codeTime)
  644. this.setData({
  645. active2code: '',
  646. activeNum: this.activeNum++,
  647. codeName: '60s后重新获取',
  648. })
  649. this.codeSetInterval(60)
  650. } else {
  651. this.setData({
  652. showToastObj: {
  653. icon: 'iconSueecss',
  654. title: res.message,
  655. status: true
  656. }
  657. })
  658. setTimeout(() => {
  659. this.setData({
  660. showToastObj: {
  661. icon: 'iconSueecss',
  662. title: res.message,
  663. status: false
  664. }
  665. })
  666. }, 2500)
  667. }
  668. })
  669. } else {
  670. wx.showToast({
  671. icon: 'error',
  672. title: '请填写验证码'
  673. })
  674. }
  675. },
  676. // 短信定时器
  677. codeSetInterval(num) {
  678. console.log(num)
  679. let time = num
  680. this.data.codeTime = setInterval(() => {
  681. if (time <= 1) {
  682. this.setData({
  683. codeName: '重新获取验证码',
  684. })
  685. clearInterval(this.data.codeTime)
  686. } else {
  687. time--
  688. this.setData({
  689. codeName:`${time}s后重新获取`
  690. })
  691. }
  692. }, 1000)
  693. },
  694. getPaySend(){
  695. if (this.data.activeNum === 1) {
  696. console.log('发送短信')
  697. Integralinfo.getPaySend({
  698. order_no: this.data.active1obj.order_no,
  699. mobile: this.data.mobile,
  700. shopid: this.data.shopid,
  701. }).then(res => {
  702. if (res.code === '0000') {
  703. this.setData({
  704. codeName: '60s后重新获取',
  705. })
  706. this.codeSetInterval(60)
  707. } else {
  708. this.setData({
  709. showToastObj: {
  710. icon: 'iconSueecss',
  711. title: res.message,
  712. status: true
  713. }
  714. })
  715. setTimeout(() => {
  716. this.setData({
  717. showToastObj: {
  718. icon: 'iconSueecss',
  719. title: res.message,
  720. status: false
  721. }
  722. })
  723. }, 2500)
  724. }
  725. })
  726. }
  727. },
  728. // 重新获取短信
  729. getCodeClick() {
  730. console.log(this.data.activeNum,this.data.codeName,this.data.active1obj.step)
  731. if ((this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') && this.data.active1obj.step === 1) {
  732. Integralinfo.getSendCmccSms({
  733. orderId: this.data.active1obj.orderId,
  734. mobile: this.data.mobile,
  735. shopid: this.data.shopid
  736. }).then(res => {
  737. if (res.code === '0000') {
  738. this.setData({
  739. codeName: '60s后重新获取',
  740. })
  741. this.codeSetInterval(60)
  742. const obj = this.data.active1obj
  743. obj.date = Math.round(new Date().getTime() / 1000).toString()
  744. wx.setStorageSync('orderDetails', JSON.stringify(obj))
  745. } else {
  746. this.setData({
  747. showToastObj: {
  748. icon: 'iconSueecss',
  749. title: res.message,
  750. status: true
  751. }
  752. })
  753. setTimeout(() => {
  754. this.setData({
  755. showToastObj: {
  756. icon: 'iconSueecss',
  757. title: res.message,
  758. status: false
  759. }
  760. })
  761. }, 2500)
  762. }
  763. });
  764. } else {
  765. if (this.data.activeNum === 0 && this.data.codeName === '重新获取验证码') {
  766. Integralinfo.getSendCmccSms({
  767. orderId: this.data.active1obj.orderId,
  768. mobile: this.data.mobile,
  769. shopid: this.data.shopid
  770. }).then(res => {
  771. if (res.code === '0000') {
  772. this.codeName = '60s后重新获取'
  773. this.codeSetInterval(60)
  774. } else {
  775. this.setData({
  776. showToastObj: {
  777. icon: 'iconSueecss',
  778. title: res.message,
  779. status: true
  780. }
  781. })
  782. setTimeout(() => {
  783. this.setData({
  784. showToastObj: {
  785. icon: 'iconSueecss',
  786. title: res.message,
  787. status: false
  788. }
  789. })
  790. }, 2500)
  791. }
  792. });
  793. } else if (this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') {
  794. console.log('短信')
  795. Integralinfo.getPaySend({
  796. order_no: this.data.active1obj.order_no,
  797. mobile: this.data.mobile,
  798. shopid: this.data.shopid,
  799. }).then(res => {
  800. if (res.code === '0000') {
  801. this.setData({
  802. codeName: '60s后重新获取',
  803. })
  804. this.codeSetInterval(60)
  805. } else {
  806. this.setData({
  807. showToastObj: {
  808. icon: 'iconSueecss',
  809. title: res.message,
  810. status: true
  811. }
  812. })
  813. setTimeout(() => {
  814. this.setData({
  815. showToastObj: {
  816. icon: 'iconSueecss',
  817. title: res.message,
  818. status: false
  819. }
  820. })
  821. }, 2500)
  822. }
  823. });
  824. }
  825. }
  826. },
  827. toExchange(){
  828. const obj = {
  829. mobile: getMobileCache(),
  830. channelid: this.data.channelid,
  831. shopid: this.data.shopid,
  832. storeid: this.data.storeid
  833. }
  834. wx.navigateTo({
  835. url: '../integral/exchange?obj=' + JSON.stringify(obj)
  836. })
  837. }
  838. })