integral.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  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. getPhoneNumberSync(e, async () => {
  277. console.log(e)
  278. if (getMobileCache() == '') {
  279. wx.showToast({
  280. icon:'error',
  281. title:'先查询移动积分'
  282. })
  283. setTimeout(()=>{
  284. that.data.setPhone = ''
  285. that.scoreClick()
  286. wx.hideLoading()
  287. },500)
  288. } else {
  289. var reg = /^(\d{3})\d{4}(\d{4})$/;
  290. this.setData({
  291. isLogin: true,
  292. setPhone: getMobileCache(),
  293. mobile: getMobileCache(),
  294. phone: getMobileCache().replace(reg, "$1****$2")
  295. })
  296. // console.log(this.data.setPhone)
  297. // console.log(this.data.mobile)
  298. // console.log(this.data.phone)
  299. this.getphoneClick()
  300. }
  301. })
  302. },
  303. // 查询积分
  304. scoreClick() {
  305. this.setData({
  306. bgStatus: true,
  307. scorePhone: true,
  308. })
  309. },
  310. // 查询积分
  311. getphoneClick() {
  312. console.log(this.data.setPhone)
  313. if (!(/^1[3456789]\d{9}$/.test(this.data.setPhone))) {
  314. wx.showToast({
  315. title: '填写正确手机号',
  316. icon: 'error',
  317. duration: 2000
  318. });
  319. } else if (this.data.setPhone != '') {
  320. // wx.showLoading({
  321. // title: '加载中'
  322. // });
  323. Integralinfo.getBalance({
  324. mobile: getMobileCache(),
  325. callbackUrl: '../integral/integral.wxml',
  326. fingerprint: '',
  327. sessionid: '',
  328. shopid: this.data.shopid,
  329. type: 'wx',
  330. }).then(arr => {
  331. console.log(arr)
  332. wx.hideLoading();
  333. if (arr.code === '0000') {
  334. var reg = /^(\d{3})\d{4}(\d{4})$/;
  335. this.setData({
  336. integralNum: arr.data,
  337. setPhone: getMobileCache(),
  338. phone: getMobileCache().replace(reg, "$1****$2"),
  339. })
  340. // this.data.integralNum = arr.data
  341. // var reg = /^(\d{3})\d{4}(\d{4})$/;
  342. // this.data.mobile = this.data.setPhone
  343. // this.data.setPhone = this.data.setPhone.replace(reg, "$1****$2");
  344. let response = {
  345. points: arr.data,
  346. outTokenId: this.data.setPhone + '_out'
  347. }
  348. // App.globalData.AppShow = response
  349. this.hideModal()
  350. this.getCouponList()
  351. wx.pageScrollTo({
  352. scrollTop: 0
  353. });
  354. let dateNum = Math.round(new Date().getTime() / 1000).toString()
  355. if (wx.getStorageSync('orderDetails') != '' && this.data.mobile === JSON.parse(wx
  356. .getStorageSync('orderDetails')).mobile) {
  357. if (dateNum - JSON.parse(wx.getStorageSync('orderDetails')).date <= 120) {
  358. const data = JSON.parse(wx.getStorageSync('orderDetails'))
  359. if (dateNum - data.date < 60) {
  360. let time = dateNum - data.date
  361. this.data.codeName = 60 - time + 's后重新获取'
  362. this.codeSetInterval(60 - time)
  363. } else {
  364. this.data.codeName = '重新获取验证码'
  365. }
  366. this.setData({
  367. paymentStatus: true,
  368. paymentBgStatus: true,
  369. active1code: '',
  370. active2code: '',
  371. active1obj: data,
  372. })
  373. if (data.step === 1) {
  374. this.data.activeNum = 1
  375. } else if (data.step === 2) {
  376. this.data.activeNum = 0
  377. }
  378. }
  379. }
  380. } else {
  381. this.setData({
  382. loading: true,
  383. bgStatus: true
  384. })
  385. setTimeout(() => {
  386. // #ifdef H5
  387. window.location.href = arr.message;
  388. // #endif
  389. // #ifdef MP-WEIXIN
  390. const version = wx.getSystemInfoSync().SDKVersion
  391. if (this.compareVersion(version, '2.20.1') >= 0) {
  392. wx.openEmbeddedMiniProgram({
  393. appId: arr.data.appId,
  394. path: arr.data.path,
  395. extraData: arr.data.extraData,
  396. success(res) {
  397. // 打开成功
  398. },
  399. fail() {}
  400. })
  401. } else {
  402. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  403. wx.navigateToMiniProgram({
  404. appId: arr.data.appId,
  405. path: arr.data.path,
  406. extraData: arr.data.extraData,
  407. success(res) {
  408. // 打开成功
  409. },
  410. fail() {
  411. }
  412. })
  413. }
  414. // #endif
  415. this.hideModal()
  416. this.loading = false
  417. }, 4000)
  418. }
  419. }).catch(error => {
  420. console.log(error)
  421. })
  422. }
  423. },
  424. // 商品数量减少按钮
  425. reduceClick(e) {
  426. console.log(e.currentTarget.dataset.index)
  427. let index = e.currentTarget.dataset.index
  428. this.data.couponList[index].quantity--
  429. this.data.total -= parseInt(this.data.couponList[index].integral)
  430. this.setData({
  431. total: this.data.total,
  432. couponList: this.data.couponList
  433. })
  434. },
  435. // 商品数量添加按钮
  436. addClick(e) {
  437. let index = e.currentTarget.dataset.index
  438. if (this.data.phone !== '********') {
  439. if (this.data.total + parseInt(this.data.couponList[index].integral) > 20000) {
  440. wx.showToast({
  441. title: '单笔限额两万分',
  442. icon: 'error',
  443. duration: 2000
  444. });
  445. } else if ((this.data.integralNum - this.data.total) >= this.data.couponList[index].integral) {
  446. this.data.couponList[index].quantity++
  447. this.data.total += parseInt(this.data.couponList[index].integral)
  448. this.setData({
  449. total: this.data.total,
  450. couponList:this.data.couponList
  451. })
  452. } else {
  453. wx.showToast({
  454. title: '积分不足',
  455. icon: 'error',
  456. duration: 2000
  457. });
  458. }
  459. } else {
  460. wx.showToast({
  461. title: '先查询移动积分',
  462. icon: 'error',
  463. duration: 1000
  464. });
  465. setTimeout(() => {
  466. this.scoreClick()
  467. }, 1000)
  468. }
  469. },
  470. /** 刷新 */
  471. shuaxinClick() {
  472. Integralinfo.getBalance({
  473. mobile: getMobileCache(),
  474. callbackUrl: '../integral/integral.wxml',
  475. fingerprint: '',
  476. sessionid: '',
  477. shopid: this.data.shopid,
  478. type: 'wx',
  479. }).then(arr => {
  480. if (arr.code === '0000') {
  481. wx.hideLoading();
  482. wx.showToast({
  483. title: '查询成功!',
  484. icon: 'success',
  485. duration: 1000
  486. });
  487. var reg = /^(\d{3})\d{4}(\d{4})$/;
  488. this.setData({
  489. integralNum: arr.data,
  490. setPhone: getMobileCache(),
  491. phone: getMobileCache().replace(reg, "$1****$2"),
  492. })
  493. }
  494. }).catch(error=>{
  495. console.log(222222)
  496. console.log(error)
  497. })
  498. },
  499. // 支付按钮
  500. paymentClick() {
  501. console.log(this.data.mobile)
  502. if (this.data.mobile === '********') {
  503. setTimeout(() => {
  504. this.scoreClick()
  505. }, 1000)
  506. wx.showToast({
  507. title: '先查询移动积分',
  508. icon: 'error',
  509. duration: 1000
  510. });
  511. } else if (this.data.total === 0) {
  512. wx.showToast({
  513. title: '请选择商品数量',
  514. icon: 'error',
  515. duration: 2000
  516. });
  517. } else {
  518. const data = []
  519. this.data.couponList.forEach(v => {
  520. if (v.quantity > 0) {
  521. data.push({
  522. couponid: v.id,
  523. num: v.quantity,
  524. })
  525. }
  526. })
  527. // let fingerprint = ''
  528. // let sessionid = ''
  529. // // #ifndef MP-WEIXIN
  530. // fingerprint = window.fmOpt
  531. // sessionid = window.sessionId
  532. // // #endif
  533. Integralinfo.getOrder({
  534. fingerprint:'',
  535. list: data,
  536. mobile: getMobileCache(),
  537. tgid: this.data.tgid,
  538. sessionid:'',
  539. shopid: this.data.shopid
  540. }).then(res => {
  541. if (res.code === '0000') {
  542. this.codeSetInterval(60)
  543. this.setData({
  544. codeName: '60s后重新获取',
  545. paymentStatus: true,
  546. paymentBgStatus: true,
  547. active1code: '',
  548. active2code: '',
  549. active1obj:{
  550. orderId: res.data.orderId,
  551. order_no: res.data.order_no,
  552. step: res.data.step,
  553. date: Math.round(new Date().getTime() / 1000).toString(),
  554. mobile: getMobileCache()
  555. },
  556. })
  557. wx.setStorageSync('orderDetails', JSON.stringify(this.data.active1obj))
  558. if (res.data.step === 1) {
  559. this.setData({
  560. activeNum: 1,
  561. })
  562. } else if (res.data.step === 2) {
  563. this.setData({
  564. activeNum: 0,
  565. })
  566. }
  567. // this.getPaySend()
  568. } else {
  569. console.log(res.data.message)
  570. console.log(this.data.integralNum,this.data.mobile,JSON.stringify(data))
  571. // log.error(`${res.data.message}`)
  572. // log.error(`${this.data.integralNum},${this.data.mobile},${JSON.stringify(data)}`)
  573. this.setData({
  574. showToastObj: {
  575. icon: 'iconSueecss',
  576. title: res.data.message,
  577. status: true
  578. }
  579. })
  580. setTimeout(() => {
  581. this.setData({
  582. showToastObj: {
  583. icon: 'iconSueecss',
  584. title: res.data.message,
  585. status: false
  586. }
  587. })
  588. }, 2500)
  589. }
  590. }).catch(error=>{
  591. console.log('zhifu')
  592. console.log(error)
  593. })
  594. }
  595. },
  596. // 步骤按钮
  597. nextCodeClick() {
  598. console.log(this.data.activeNum,this.data.active2code)
  599. if (this.data.activeNum === 1 && this.data.active2code !== '') {
  600. // wx.showLoading({
  601. // title: '兑换中'
  602. // });
  603. // let fingerprint = ''
  604. // let sessionid = ''
  605. // // #ifndef MP-WEIXIN
  606. // fingerprint = window.fmOpt
  607. // sessionid = window.sessionId
  608. // #endif
  609. Integralinfo.getPayOnce({
  610. fingerprint: '',
  611. mobile: getMobileCache(),
  612. optCode: this.data.active2code,
  613. order_no: this.data.active1obj.order_no,
  614. orderId: this.data.active1obj.orderId,
  615. sessionid: '',
  616. shopid: this.data.shopid
  617. }).then(res => {
  618. if (res.code === '0000') {
  619. const obj = {
  620. mobile: this.data.mobile,
  621. channelid: this.data.channelid,
  622. shopid: this.data.shopid,
  623. storeid: this.data.storeid
  624. }
  625. this.data.integralNum -= this.data.total
  626. this.setData({
  627. integralNum: this.data.integralNum,
  628. total: 0,
  629. listStatus: false,
  630. listTrue: [],
  631. })
  632. this.data.couponList.forEach((v)=>{
  633. v.quantity = 0
  634. })
  635. this.setData({
  636. couponList: this.data.couponList,
  637. paymentStatus: false,
  638. paymentBgStatus: false,
  639. })
  640. wx.setStorageSync('orderDetails', null)
  641. wx.hideLoading();
  642. wx.navigateTo({
  643. url: '../integral/success?row=' + JSON.stringify(obj)
  644. })
  645. } else {
  646. wx.hideLoading();
  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. }).catch(error => {
  665. let res = error.data;
  666. wx.showToast({
  667. icon: 'none',
  668. title: res.message
  669. })
  670. });
  671. } else if (this.data.activeNum === 0 && this.data.active1code !== '') {
  672. Integralinfo.getExchange({
  673. fingerprint: '',
  674. mobile: getMobileCache(),
  675. optCode: this.data.active1code,
  676. orderId: this.data.active1obj.orderId,
  677. order_no: this.data.active1obj.order_no,
  678. sessionid: '',
  679. shopid: this.data.shopid
  680. }).then(res => {
  681. if (res.code === '0000') {
  682. clearInterval(this.data.codeTime)
  683. this.setData({
  684. active2code: '',
  685. activeNum: this.activeNum++,
  686. codeName: '60s后重新获取',
  687. })
  688. this.codeSetInterval(60)
  689. } else {
  690. this.setData({
  691. showToastObj: {
  692. icon: 'iconSueecss',
  693. title: res.message,
  694. status: true
  695. }
  696. })
  697. setTimeout(() => {
  698. this.setData({
  699. showToastObj: {
  700. icon: 'iconSueecss',
  701. title: res.message,
  702. status: false
  703. }
  704. })
  705. }, 2500)
  706. }
  707. }).catch(error => {
  708. let res = error.data;
  709. wx.showToast({
  710. icon: 'none',
  711. title: res.message
  712. })
  713. })
  714. } else {
  715. wx.showToast({
  716. icon: 'error',
  717. title: '请填写验证码'
  718. })
  719. }
  720. },
  721. // 短信定时器
  722. codeSetInterval(num) {
  723. console.log(num)
  724. let time = num
  725. this.data.codeTime = setInterval(() => {
  726. if (time <= 1) {
  727. this.setData({
  728. codeName: '重新获取验证码',
  729. })
  730. clearInterval(this.data.codeTime)
  731. } else {
  732. time--
  733. this.setData({
  734. codeName:`${time}s后重新获取`
  735. })
  736. }
  737. }, 1000)
  738. },
  739. getPaySend(){
  740. if (this.data.activeNum === 1) {
  741. console.log('发送短信')
  742. Integralinfo.getPaySend({
  743. order_no: this.data.active1obj.order_no,
  744. mobile: getMobileCache(),
  745. shopid: this.data.shopid,
  746. }).then(res => {
  747. if (res.code === '0000') {
  748. this.setData({
  749. codeName: '60s后重新获取',
  750. })
  751. this.codeSetInterval(60)
  752. } else {
  753. this.setData({
  754. showToastObj: {
  755. icon: 'iconSueecss',
  756. title: res.message,
  757. status: true
  758. }
  759. })
  760. setTimeout(() => {
  761. this.setData({
  762. showToastObj: {
  763. icon: 'iconSueecss',
  764. title: res.message,
  765. status: false
  766. }
  767. })
  768. }, 2500)
  769. }
  770. }).catch(error=>{
  771. console.log('duanxin')
  772. console.log(error)
  773. })
  774. }
  775. },
  776. // 重新获取短信
  777. getCodeClick() {
  778. console.log(this.data.activeNum,this.data.codeName,this.data.active1obj.step)
  779. if ((this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') && this.data.active1obj.step === 1) {
  780. Integralinfo.getSendCmccSms({
  781. orderId: this.data.active1obj.orderId,
  782. mobile: getMobileCache(),
  783. shopid: this.data.shopid
  784. }).then(res => {
  785. if (res.code === '0000') {
  786. this.setData({
  787. codeName: '60s后重新获取',
  788. })
  789. this.codeSetInterval(60)
  790. const obj = this.data.active1obj
  791. obj.date = Math.round(new Date().getTime() / 1000).toString()
  792. wx.setStorageSync('orderDetails', JSON.stringify(obj))
  793. } else {
  794. this.setData({
  795. showToastObj: {
  796. icon: 'iconSueecss',
  797. title: res.message,
  798. status: true
  799. }
  800. })
  801. setTimeout(() => {
  802. this.setData({
  803. showToastObj: {
  804. icon: 'iconSueecss',
  805. title: res.message,
  806. status: false
  807. }
  808. })
  809. }, 2500)
  810. }
  811. }).catch(error=>{
  812. console.log('chongxin')
  813. console.log(error)
  814. });
  815. } else {
  816. if (this.data.activeNum === 0 && this.data.codeName === '重新获取验证码') {
  817. Integralinfo.getSendCmccSms({
  818. orderId: this.data.active1obj.orderId,
  819. mobile: getMobileCache(),
  820. shopid: this.data.shopid
  821. }).then(res => {
  822. if (res.code === '0000') {
  823. this.codeName = '60s后重新获取'
  824. this.codeSetInterval(60)
  825. } else {
  826. this.setData({
  827. showToastObj: {
  828. icon: 'iconSueecss',
  829. title: res.message,
  830. status: true
  831. }
  832. })
  833. setTimeout(() => {
  834. this.setData({
  835. showToastObj: {
  836. icon: 'iconSueecss',
  837. title: res.message,
  838. status: false
  839. }
  840. })
  841. }, 2500)
  842. }
  843. }).catch(error=>{
  844. console.log('chongxin')
  845. console.log(error)
  846. });
  847. } else if (this.data.activeNum === 1 && this.data.codeName === '重新获取验证码') {
  848. console.log('短信')
  849. Integralinfo.getPaySend({
  850. order_no: this.data.active1obj.order_no,
  851. mobile: getMobileCache(),
  852. shopid: this.data.shopid,
  853. }).then(res => {
  854. if (res.code === '0000') {
  855. this.setData({
  856. codeName: '60s后重新获取',
  857. })
  858. this.codeSetInterval(60)
  859. } else {
  860. this.setData({
  861. showToastObj: {
  862. icon: 'iconSueecss',
  863. title: res.message,
  864. status: true
  865. }
  866. })
  867. setTimeout(() => {
  868. this.setData({
  869. showToastObj: {
  870. icon: 'iconSueecss',
  871. title: res.message,
  872. status: false
  873. }
  874. })
  875. }, 2500)
  876. }
  877. }).catch(error=>{
  878. console.log('chongxin')
  879. console.log(error)
  880. });
  881. }
  882. }
  883. },
  884. toExchange(){
  885. const obj = {
  886. mobile: getMobileCache(),
  887. channelid: this.data.channelid,
  888. shopid: this.data.shopid,
  889. storeid: this.data.storeid
  890. }
  891. wx.navigateTo({
  892. url: '../integral/exchange?obj=' + JSON.stringify(obj)
  893. })
  894. }
  895. })