integral.js 28 KB

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