integral.js 30 KB

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