integral.js 30 KB

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