order.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template>
  2. <view class="ezy-order-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">我的订单</text>
  6. </view>
  7. <view class="ezy-tab-border">
  8. <uni-segmented-control :current="dingdanData.current" :values="dingdanData.items" active-color="#3A7FE9"
  9. @clickItem="onChangeTab" class="ezy-tab-box" />
  10. <view>
  11. <view v-if="dingdanData.current == 0">
  12. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  13. :refresher-triggered="dingdanData.quanbu.loading" :refresher-threshold="50"
  14. refresher-background="transparent" @refresherrefresh="onRefresh" class="order-scroll-view">
  15. <!--数学-->
  16. <uni-list>
  17. <uni-list-item v-for="(item,index) in dingdanData.quanbu.list" :key="index"
  18. class="order-list-item">
  19. <template v-slot:body>
  20. <view class="order-item-head">
  21. <view class="order-name-box">
  22. <icon></icon><text>鹅状元自营</text>
  23. </view>
  24. <view>
  25. <text>不支持退订</text>
  26. <text v-if="item.status ==2" class="pay-status">已付款</text>
  27. <text v-if="item.status ==3" class="pay-status">已关闭</text>
  28. <text v-if="item.status ==1" class="pay-status">待付款</text>
  29. </view>
  30. </view>
  31. <view class="order-content-box" @click="goDao(item2,index2)" v-for="(item2,index2) in item.cardList"
  32. :key="index2">
  33. <!-- 需要改成从接口获取的 wgy-->
  34. <img class="content-img" :src="item2.cover">
  35. <view class="content-body-box">
  36. <view class="content-name">{{item2.cardName}}</view>
  37. <view class="content-text">{{item2.intro}}</view>
  38. <!-- 未付款数据对一下 是否有课程包明细 wgy-->
  39. <view class="content-money-box">
  40. <view class="order-kcb-btn" v-if="item2.type ==1"
  41. @click.stop="detailBtn(item2,index2)">课程包明细<icon></icon>
  42. </view>
  43. <text class="content-yuanjia">¥{{item2.xianjia}}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="content-heji" v-if="item.cardList.length>1">合计:¥{{item.money}}</view>
  48. <view v-if="item.status !=2" class="order-bottom-box">
  49. <view class="pay-status-box"
  50. v-if="payType =='weixin'&&currentPlatform =='android'"
  51. @click="switchPayWay">
  52. <icon class="wx-icon"></icon>微信
  53. </view>
  54. <view class="pay-status-box"
  55. v-if="payType =='zhifubao'&&currentPlatform =='android'"
  56. @click="switchPayWay">
  57. <icon class="zfb-icon"></icon>支付宝
  58. </view>
  59. <view class="pay-status-box apple-status-box" v-if="currentPlatform =='ios'">
  60. <icon class="apple-icon"></icon>apple
  61. </view>
  62. <view v-if="currentPlatform =='android'" class="pay-btn"
  63. @touchstart="creatOrder(item.cardList,index)">立即支付
  64. </view>
  65. <view v-if="currentPlatform =='ios'"
  66. class="pay-btn" @touchstart="creatOrderIos(item.cardList,index)">立即支付
  67. </view>
  68. </view>
  69. <!-- 未付款显示付款按钮 wgy-->
  70. <!-- <payComponents ref="payComponentsRef">
  71. <view v-if="currentPlatform =='android'" class="pay-btn" @touchstart="creatOrder(item,index)">立即支付
  72. </view>
  73. <view v-if="currentPlatform =='ios'" class="pay-btn"
  74. @touchstart="creatOrderIos(item,index)">立即支付</view>
  75. </payComponents> -->
  76. </template>
  77. </uni-list-item>
  78. <uni-load-more :status="dingdanData.quanbu.state" @click="getMore(0)"
  79. :contentText="dingdanData.quanbu.contentText">
  80. </uni-load-more>
  81. </uni-list>
  82. </scroll-view>
  83. </view>
  84. <view v-if="dingdanData.current == 1">
  85. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  86. :refresher-triggered="dingdanData.daiFukuan.loading" :refresher-threshold="50"
  87. refresher-background="transparent" @refresherrefresh="onRefresh" class="order-scroll-view">
  88. <!--数学-->
  89. <uni-list>
  90. <uni-list-item v-for="(item,index) in dingdanData.daiFukuan.list" :key="index"
  91. class="order-list-item">
  92. <template v-slot:body>
  93. <view class="order-item-head">
  94. <view class="order-name-box">
  95. <icon></icon><text>鹅状元自营</text>
  96. </view>
  97. <view>
  98. <text>不支持退订</text>
  99. <text v-if="item.status ==2" class="pay-status">已付款</text>
  100. <text v-if="item.status ==3" class="pay-status">已关闭</text>
  101. <text v-if="item.status ==1" class="pay-status">待付款</text>
  102. </view>
  103. </view>
  104. <view class="order-content-box" v-for="(item2,index2) in item.cardList"
  105. :key="index2">
  106. <!-- 需要改成从接口获取的 wgy-->
  107. <img class="content-img" :src="item2.cover">
  108. <view class="content-body-box">
  109. <view class="content-name">{{item2.cardName}}</view>
  110. <view class="content-text">{{item2.intro}}</view>
  111. <!-- 未付款数据对一下 是否有课程包明细 wgy-->
  112. <view class="content-money-box">
  113. <view class="order-kcb-btn" v-if="item2.type ==1"
  114. @click="detailBtn(item2,index2)">课程包明细<icon></icon>
  115. </view>
  116. <text class="content-yuanjia">¥{{item2.xianjia}}</text>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="content-heji" v-if="item.cardList.length>1">合计:¥{{item.money}}</view>
  121. <view v-if="item.status !=2" class="order-bottom-box">
  122. <view class="pay-status-box"
  123. v-if="payType =='weixin'&&currentPlatform =='android'"
  124. @click="switchPayWay">
  125. <icon class="wx-icon"></icon>微信
  126. </view>
  127. <view class="pay-status-box"
  128. v-if="payType =='zhifubao'&&currentPlatform =='android'"
  129. @click="switchPayWay">
  130. <icon class="zfb-icon"></icon>支付宝
  131. </view>
  132. <view class="pay-status-box apple-status-box" v-if="currentPlatform =='ios'">
  133. <icon class="apple-icon"></icon>apple
  134. </view>
  135. <view v-if="currentPlatform =='android'" class="pay-btn"
  136. @touchstart="creatOrder(item.cardList,index)">立即支付
  137. </view>
  138. <view v-if="currentPlatform =='ios'"
  139. class="pay-btn" @touchstart="creatOrderIos(item.cardList,index)">立即支付
  140. </view>
  141. </view>
  142. <!-- 未付款显示付款按钮 wgy-->
  143. <!-- <payComponents ref="payComponentsRef">
  144. <view v-if="currentPlatform =='android'" class="pay-btn" @touchstart="creatOrder(item,index)">立即支付
  145. </view>
  146. <view v-if="currentPlatform =='ios'" class="pay-btn"
  147. @touchstart="creatOrderIos(item,index)">立即支付</view>
  148. </payComponents> -->
  149. </template>
  150. </uni-list-item>
  151. <uni-load-more :status="dingdanData.daiFukuan.state" @click="getMore(1)"
  152. :contentText="dingdanData.daiFukuan.contentText">
  153. </uni-load-more>
  154. </uni-list>
  155. </scroll-view>
  156. </view>
  157. <view v-if="dingdanData.current == 2">
  158. <scroll-view scroll-y="true" refresher-enabled="true" @scrolltolower="onScrolltolower"
  159. :refresher-triggered="dingdanData.yiFukuan.loading" :refresher-threshold="50"
  160. refresher-background="transparent" @refresherrefresh="onRefresh" class="order-scroll-view">
  161. <!--数学-->
  162. <uni-list>
  163. <uni-list-item v-for="(item,index) in dingdanData.yiFukuan.list" :key="index"
  164. class="order-list-item">
  165. <template v-slot:body>
  166. <view class="order-item-head">
  167. <view class="order-name-box">
  168. <icon></icon><text>鹅状元自营</text>
  169. </view>
  170. <view>
  171. <text>不支持退订</text>
  172. <text v-if="item.status ==2" class="pay-status">已付款</text>
  173. <text v-if="item.status ==3" class="pay-status">已关闭</text>
  174. <text v-if="item.status ==1" class="pay-status">待付款</text>
  175. </view>
  176. </view>
  177. <view class="order-content-box" @click="goDao(item2,index2)" v-for="(item2,index2) in item.cardList"
  178. :key="index2">
  179. <!-- 需要改成从接口获取的 wgy-->
  180. <img class="content-img" :src="item2.cover">
  181. <view class="content-body-box">
  182. <view class="content-name">{{item2.cardName}}</view>
  183. <view class="content-text">{{item2.intro}}</view>
  184. <!-- 未付款数据对一下 是否有课程包明细 wgy-->
  185. <view class="content-money-box">
  186. <view class="order-kcb-btn" v-if="item2.type ==1"
  187. @click="detailBtn(item2,index2)">课程包明细<icon></icon>
  188. </view>
  189. <text class="content-yuanjia">¥{{item2.xianjia}}</text>
  190. </view>
  191. </view>
  192. </view>
  193. <view class="content-heji" v-if="item.cardList.length>1">合计:¥{{item.money}}</view>
  194. <view v-if="item.status !=2" class="order-bottom-box">
  195. <view class="pay-status-box"
  196. v-if="payType =='weixin'&&currentPlatform =='android'"
  197. @click="switchPayWay">
  198. <icon class="wx-icon"></icon>微信
  199. </view>
  200. <view class="pay-status-box"
  201. v-if="payType =='zhifubao'&&currentPlatform =='android'"
  202. @click="switchPayWay">
  203. <icon class="zfb-icon"></icon>支付宝
  204. </view>
  205. <view class="pay-status-box apple-status-box" v-if="currentPlatform =='ios'">
  206. <icon class="apple-icon"></icon>apple
  207. </view>
  208. <view v-if="currentPlatform =='android'" class="pay-btn"
  209. @touchstart="creatOrder(item.cardList,index)">立即支付
  210. </view>
  211. <view v-if="currentPlatform =='ios'"
  212. class="pay-btn" @touchstart="creatOrderIos(item.cardList,index)">立即支付
  213. </view>
  214. </view>
  215. <!-- 未付款显示付款按钮 wgy-->
  216. <!-- <payComponents ref="payComponentsRef">
  217. <view v-if="currentPlatform =='android'" class="pay-btn" @touchstart="creatOrder(item,index)">立即支付
  218. </view>
  219. <view v-if="currentPlatform =='ios'" class="pay-btn"
  220. @touchstart="creatOrderIos(item,index)">立即支付</view>
  221. </payComponents> -->
  222. </template>
  223. </uni-list-item>
  224. <uni-load-more :status="dingdanData.yiFukuan.state" @click="getMore(2)"
  225. :contentText="dingdanData.yiFukuan.contentText">
  226. </uni-load-more>
  227. </uni-list>
  228. </scroll-view>
  229. </view>
  230. </view>
  231. </view>
  232. <product-dialog ref="mallProductPopup"></product-dialog>
  233. <CustomTabBar></CustomTabBar>
  234. </view>
  235. </template>
  236. <script setup>
  237. import {
  238. reactive,
  239. ref
  240. } from "vue";
  241. import {
  242. orderAdd,
  243. orderPayAli,
  244. orderPayWx,
  245. orderPayApple,
  246. getOrderList,
  247. orderInfo,
  248. orderCheck
  249. } from "@/api/order.js"
  250. import {
  251. onLoad
  252. } from "@dcloudio/uni-app";
  253. import {
  254. toast,
  255. debounce,
  256. getUserIdentity
  257. } from "@/utils/common";
  258. import cacheManager from '@/utils/cacheManager.js';
  259. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  260. import payComponents from '@/components/payComponents/index.vue';
  261. import productDialog from './productDialog.vue'
  262. const mallProductPopup = ref(null);
  263. const payComponentsRef = ref(null);
  264. const showPayWay = ref(true)
  265. let currentPlatform = ref('android')
  266. const payType = ref('weixin');
  267. let orderId = ref('');
  268. let productId = ref(null)
  269. let iapChannel = ref(null)
  270. let quantity = ref(1)
  271. let channel = ref('')
  272. let appleFlag = ref('')
  273. function switchPayWay() {
  274. payType.value = payType.value == 'weixin' ? 'zhifubao' : 'weixin'
  275. }
  276. function detailBtn(data, index) {
  277. mallProductPopup.value.detailShow(data.levelList);
  278. }
  279. const dingdanData = reactive({
  280. items: ['全部', '待付款', '已付款'],
  281. current: 0,
  282. quanbu: {
  283. page: 0,
  284. list: [],
  285. loading: false,
  286. state: 'more',
  287. contentText: {
  288. contentdown: '查看更多',
  289. contentrefresh: '加载中',
  290. contentnomore: '没有更多'
  291. }
  292. },
  293. daiFukuan: {
  294. page: 0,
  295. list: [],
  296. loading: false,
  297. state: 'more',
  298. contentText: {
  299. contentdown: '查看更多',
  300. contentrefresh: '加载中',
  301. contentnomore: '没有更多'
  302. }
  303. },
  304. yiFukuan: {
  305. page: 0,
  306. list: [],
  307. loading: false,
  308. state: 'more',
  309. contentText: {
  310. contentdown: '查看更多',
  311. contentrefresh: '加载中',
  312. contentnomore: '没有更多'
  313. }
  314. },
  315. })
  316. function goDao(data,index){
  317. console.log('data',data);
  318. console.log('index',index);
  319. if(data.type ==0 &&data.levelList.length ==1){
  320. cacheManager.updateObject('auth', {
  321. typeId: data.levelList[0].typeId,
  322. levelId: data.levelList[0].levelId,
  323. subjectId: data.levelList[0].subjectId,
  324. currentZhang: 0
  325. })
  326. cacheManager.remove('daoPageCache')
  327. uni.redirectTo({
  328. url: `/pages/study/index`
  329. })
  330. }
  331. }
  332. function genggaiVip(data) {
  333. uni.hideLoading();
  334. const localList = cacheManager.get('auth').levelIdList || []
  335. const mergeList = [...new Set([...localList, ...data.levelIdList])]
  336. cacheManager.updateObject('auth', {
  337. levelIdList: mergeList
  338. })
  339. toast("支付成功")
  340. dingdanData.current = 2
  341. getMore(2)
  342. // if (formPage.value == 'my') {
  343. // uni.redirectTo({
  344. // url: '/pages/my/index'
  345. // })
  346. // } else {
  347. // uni.redirectTo({
  348. // url: '/pages/study/index'
  349. // })
  350. // }
  351. }
  352. const creatOrderIos = debounce((data, index) => {
  353. uni.showLoading({
  354. title: '',
  355. mask: true
  356. });
  357. if (appleFlag.value.toString() == 'true') {
  358. productId.value = 'llisoftEzhuangyuanceshi'
  359. } else {
  360. if (cardId.value == 1) {
  361. productId.value = 'llisoftEzhuangyuan'
  362. } else {
  363. productId.value = 'llisoftEzhuangyuanYingyu'
  364. }
  365. }
  366. uni.hideLoading();
  367. orderId.value = data.id
  368. // 测试ios 1元
  369. applePay()
  370. }, 500)
  371. function applePaySuccess(data) {
  372. uni.showLoading({
  373. title: '开通中',
  374. mask: true
  375. });
  376. let req = {
  377. "id": orderId.value,
  378. "paynum": data.transactionIdentifier,
  379. "receipt": data.transactionReceipt
  380. }
  381. console.log('reqreq', req);
  382. orderPayApple(req).then(res => {
  383. if (res.code == 0 && res.data) {
  384. iapChannel.finishTransaction(data.transactionIdentifier)
  385. console.log('resiapChanneliapChanneliapChannel', res);
  386. orderCheck({
  387. id: orderId.value
  388. }).then(res3 => {
  389. console.log('res3', res3);
  390. if (res3.code == 0&&res3.data.success) {
  391. genggaiVip(res3.data)
  392. } else {
  393. setTimeout(() => {
  394. orderCheck({
  395. id: orderId.value
  396. }).then(res4 => {
  397. if (res4.code == 0&&res4.data.success) {
  398. genggaiVip(res4.data)
  399. } else {
  400. toast(
  401. "开通失败,请联系管理员!"
  402. )
  403. uni
  404. .hideLoading();
  405. return false
  406. }
  407. }).catch(() => {
  408. uni.hideLoading();
  409. toast("check接口报错")
  410. return false
  411. })
  412. }, 5000)
  413. }
  414. }).catch(() => {
  415. uni.hideLoading();
  416. toast("check接口报错")
  417. return false
  418. })
  419. } else {
  420. iapChannel.finishTransaction(data.transactionIdentifier)
  421. uni.hideLoading();
  422. toast("苹果内购失败")
  423. console.log('orderPayApple失败');
  424. return false
  425. }
  426. })
  427. }
  428. function applePay() {
  429. console.log('123123');
  430. if (!productId.value) {
  431. uni.showToast({
  432. title: '苹果内购ID缺失,请选择其它支付方式或联系客服',
  433. icon: "none"
  434. });
  435. return false;
  436. }
  437. uni.showLoading({
  438. title: '正在支付中...'
  439. });
  440. try {
  441. plus.payment.getChannels(function(channels) { //判读项目支付通道开通情况
  442. for (var i in channels) {
  443. iapChannel = channels[i];
  444. // 获取 id 为 'appleiap' 的 channel
  445. console.info("支付通道", iapChannel)
  446. if (iapChannel.id === 'appleiap') { //开通了app应用内支付,在manifest.josn中设置,开通后需打自定议基座
  447. console.info("苹果支付通道", iapChannel)
  448. // ids 数组中的项为 App Store Connect 配置的内购买项目产品ID(productId)
  449. var ids = [productId.value];
  450. // iap 为应用内支付对象
  451. iapChannel.requestOrder(ids, function(e) {
  452. // 获取订单信息成功回调方法
  453. console.log('requestOrder success: ' + JSON.stringify(e));
  454. uni.requestPayment({
  455. provider: 'appleiap',
  456. orderInfo: {
  457. productid: productId.value, //产品id,来自于苹果
  458. quantity: quantity.value, //产品数量
  459. manualFinishTransaction: true
  460. },
  461. success: (e) => {
  462. uni.hideLoading();
  463. // toast("苹果内购成功")
  464. console.info("苹果内购成功", e)
  465. applePaySuccess(e)
  466. //e.payment.orderNo = that.orderNo
  467. //支付成功回调,前端调用后台接口
  468. },
  469. fail: (e) => {
  470. uni.hideLoading();
  471. toast("苹果内购失败")
  472. console.info("苹果内购失败", e)
  473. },
  474. })
  475. },
  476. function(e) {
  477. // 获取订单信息失败回调方法
  478. console.log('requestOrder failed: ' + JSON.stringify(e));
  479. });
  480. } else {
  481. console.log('不支持苹果支付')
  482. }
  483. }
  484. },
  485. function(e) {
  486. console.log("获取iap支付通道失败:" + e.message);
  487. });
  488. } catch (e) {
  489. uni.showModal({
  490. title: "init",
  491. content: e.message,
  492. showCancel: false
  493. });
  494. } finally {
  495. uni.hideLoading();
  496. }
  497. }
  498. function wxPay() {
  499. orderPayWx({
  500. id: orderId.value
  501. }).then(res2 => {
  502. uni.hideLoading();
  503. console.log('res2', res2);
  504. if(res2.code !=0){
  505. return false
  506. }
  507. uni.requestPayment({
  508. "provider": "wxpay",
  509. "orderInfo": {
  510. "appid": res2.data.appid, // 应用ID(AppID)
  511. "partnerid": res2.data.partnerId, // 商户号(PartnerID)
  512. "prepayid": res2.data.prepayId, // 预支付交易会话ID
  513. "package": res2.data.packageVal, // 固定值
  514. "noncestr": res2.data.nonceStr, // 随机字符串
  515. "timestamp": res2.data.timestamp, // 时间戳(单位:秒)
  516. "sign": res2.data.sign // 签名,这里用的 MD5 签名
  517. }, //此处为服务器返回的订单信息字符串
  518. success: function(res) {
  519. //var rawdata = JSON.parse(res.rawdata);
  520. // console.log('res',res);
  521. // console.log('支付成功');
  522. // console.log('rawdata', rawdata);
  523. uni.showLoading({
  524. title: '开通中,请稍后...'
  525. });
  526. orderCheck({
  527. id: orderId.value
  528. }).then(res3 => {
  529. console.log('res3', res3);
  530. if (res3.code == 0&&res3.data.success) {
  531. genggaiVip(res3.data)
  532. } else {
  533. setTimeout(() => {
  534. orderCheck({
  535. id: orderId.value
  536. }).then(res4 => {
  537. if (res4.code == 0&&res4.data.success) {
  538. genggaiVip(res4.data)
  539. } else {
  540. toast(
  541. "开通失败,请联系管理员!"
  542. )
  543. uni
  544. .hideLoading();
  545. return false
  546. }
  547. }).catch(() => {
  548. uni.hideLoading();
  549. toast("check接口报错")
  550. return false
  551. })
  552. }, 5000)
  553. }
  554. }).catch(() => {
  555. uni.hideLoading();
  556. toast("check接口报错")
  557. return false
  558. })
  559. },
  560. fail: function(err) {
  561. uni.hideLoading();
  562. // toast('支付失败:' + JSON.stringify(err));
  563. console.log('支付失败:' + JSON.stringify(err));
  564. }
  565. });
  566. }).catch((error) => {
  567. uni.hideLoading();
  568. console.log(error);
  569. })
  570. }
  571. function aliApy() {
  572. orderPayAli({
  573. id: orderId.value
  574. }).then(res2 => {
  575. console.log('res2', res2);
  576. uni.hideLoading();
  577. if(res2.code !=0){
  578. return false
  579. }
  580. uni.requestPayment({
  581. "provider": "alipay",
  582. "orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
  583. success: function(res) {
  584. // var rawdata = JSON.parse(res.rawdata);
  585. // console.log('支付成功');
  586. // console.log('rawdata', rawdata);
  587. uni.showLoading({
  588. title: '开通中,请稍后...'
  589. });
  590. orderCheck({
  591. id: orderId.value
  592. }).then(res3 => {
  593. if (res3.code == 0&&res3.data.success) {
  594. genggaiVip(res3.data)
  595. } else {
  596. setTimeout(() => {
  597. orderCheck({
  598. id: orderId.value
  599. }).then(res4 => {
  600. if (res4.code ==
  601. 0&&res4.data.success) {
  602. genggaiVip(res4.data)
  603. } else {
  604. toast(
  605. "开通失败,请联系管理员!"
  606. )
  607. uni
  608. .hideLoading();
  609. return false
  610. }
  611. }).catch(() => {
  612. uni.hideLoading();
  613. toast("check接口报错")
  614. return false
  615. })
  616. }, 5000)
  617. }
  618. }).catch(() => {
  619. uni.hideLoading();
  620. toast("check接口报错")
  621. return false
  622. })
  623. },
  624. fail: function(err) {
  625. console.log('支付失败:' + JSON.stringify(err));
  626. uni.hideLoading();
  627. }
  628. });
  629. })
  630. }
  631. const creatOrder = debounce((data, index) => {
  632. uni.showLoading({
  633. title: '',
  634. mask: true
  635. });
  636. if (payType.value == 'weixin') {
  637. orderId.value = data.id
  638. wxPay()
  639. } else {
  640. orderId.value = data.id
  641. aliApy()
  642. }
  643. }, 500)
  644. function onChangeTab(e) {
  645. if (dingdanData.current !== e.currentIndex) {
  646. dingdanData.current = e.currentIndex;
  647. if (dingdanData.current == 0) {
  648. dingdanData.quanbu.page = 0
  649. } else if (dingdanData.current == 1) {
  650. dingdanData.daiFukuan.page = 0
  651. } else if (dingdanData.current == 2) {
  652. dingdanData.yiFukuan.page = 0
  653. }
  654. refreshData(dingdanData.current);
  655. }
  656. }
  657. function onScrolltolower() {
  658. getMore(dingdanData.current)
  659. }
  660. function refreshData(code) {
  661. const opt = {
  662. page: 1,
  663. size: 10, // 固定查询10条
  664. status: code
  665. }
  666. if (code == 0) {
  667. dingdanData.quanbu.list = [];
  668. // 数学
  669. dingdanData.quanbu.state = 'loading';
  670. dingdanData.quanbu.page++;
  671. opt.page = dingdanData.quanbu.page;
  672. } else if (code == 1) {
  673. dingdanData.daiFukuan.list = [];
  674. // 英语
  675. dingdanData.daiFukuan.state = 'loading';
  676. dingdanData.daiFukuan.page++;
  677. opt.page = dingdanData.daiFukuan.page;
  678. } else if (code == 2) {
  679. dingdanData.yiFukuan.list = [];
  680. // 英语
  681. dingdanData.yiFukuan.state = 'loading';
  682. dingdanData.yiFukuan.page++;
  683. opt.page = dingdanData.yiFukuan.page;
  684. }
  685. getOrderList(opt).then(res => {
  686. if (code == 0) {
  687. dingdanData.quanbu.list = dingdanData.quanbu.list.concat(res.data.data);
  688. dingdanData.quanbu.loading = false;
  689. } else if (code == 1) {
  690. dingdanData.daiFukuan.list = dingdanData.daiFukuan.list.concat(res.data.data);
  691. dingdanData.daiFukuan.loading = false;
  692. } else if (code == 2) {
  693. dingdanData.yiFukuan.list = dingdanData.yiFukuan.list.concat(res.data.data);
  694. dingdanData.yiFukuan.loading = false;
  695. }
  696. if (code == 0) {
  697. if (res.data.total > dingdanData.quanbu.list.length) {
  698. // 数学
  699. dingdanData.quanbu.state = 'more';
  700. dingdanData.quanbu.loading = false;
  701. } else {
  702. // 数学
  703. dingdanData.quanbu.state = 'no-more';
  704. dingdanData.quanbu.loading = false;
  705. }
  706. } else if (code == 1) {
  707. if (res.data.total > dingdanData.daiFukuan.list.length) {
  708. // 英语
  709. dingdanData.daiFukuan.state = 'more';
  710. dingdanData.daiFukuan.loading = false;
  711. } else {
  712. // 英语
  713. dingdanData.daiFukuan.state = 'no-more';
  714. dingdanData.daiFukuan.loading = false;
  715. }
  716. } else if (code == 2) {
  717. if (res.data.total > dingdanData.yiFukuan.list.length) {
  718. // 英语
  719. dingdanData.yiFukuan.state = 'more';
  720. dingdanData.yiFukuan.loading = false;
  721. } else {
  722. // 英语
  723. dingdanData.yiFukuan.state = 'no-more';
  724. dingdanData.yiFukuan.loading = false;
  725. }
  726. }
  727. }).catch(err => {
  728. if (code == 0) {
  729. // 数学
  730. dingdanData.quanbu.state = 'more';
  731. dingdanData.quanbu.loading = false;
  732. } else if (code == 1) {
  733. // 英语
  734. dingdanData.daiFukuan.state = 'more';
  735. dingdanData.daiFukuan.loading = false;
  736. } else if (code == 2) {
  737. // 英语
  738. dingdanData.yiFukuan.state = 'more';
  739. dingdanData.yiFukuan.loading = false;
  740. }
  741. })
  742. }
  743. function onRefresh() {
  744. if (dingdanData.current == 0) {
  745. dingdanData.quanbu.page = 0;
  746. dingdanData.quanbu.list = [];
  747. dingdanData.quanbu.loading = true;
  748. } else if (dingdanData.current == 1) {
  749. dingdanData.daiFukuan.page = 0;
  750. dingdanData.daiFukuan.list = [];
  751. dingdanData.daiFukuan.loading = true;
  752. } else if (dingdanData.current == 2) {
  753. dingdanData.yiFukuan.page = 0;
  754. dingdanData.yiFukuan.list = [];
  755. dingdanData.yiFukuan.loading = true;
  756. }
  757. refreshData(dingdanData.current);
  758. }
  759. function getMore(code) {
  760. const opt = {
  761. page: 1,
  762. size: 10, // 固定查询10条
  763. status: Number(code) // 前台索引加1为学科cardId
  764. }
  765. if (code == 0) {
  766. if (dingdanData.quanbu.state == 'no-more') {
  767. return;
  768. }
  769. // 数学
  770. dingdanData.quanbu.state = 'loading';
  771. dingdanData.quanbu.page++;
  772. opt.page = dingdanData.quanbu.page;
  773. } else if (code == 1) {
  774. if (dingdanData.daiFukuan.state == 'no-more') {
  775. return;
  776. }
  777. dingdanData.daiFukuan.state = 'loading';
  778. dingdanData.daiFukuan.page++;
  779. opt.page = dingdanData.daiFukuan.page;
  780. } else if (code == 2) {
  781. if (dingdanData.yiFukuan.state == 'no-more') {
  782. return;
  783. }
  784. dingdanData.yiFukuan.state = 'loading';
  785. dingdanData.yiFukuan.page++;
  786. opt.page = dingdanData.yiFukuan.page;
  787. }
  788. getOrderList(opt).then(res => {
  789. if (code == 0) {
  790. dingdanData.quanbu.list = dingdanData.quanbu.list.concat(res.data.data);
  791. dingdanData.quanbu.loading = false;
  792. } else if (code == 1) {
  793. dingdanData.daiFukuan.list = dingdanData.daiFukuan.list.concat(res.data.data);
  794. dingdanData.daiFukuan.loading = false;
  795. } else if (code == 2) {
  796. dingdanData.yiFukuan.list = dingdanData.yiFukuan.list.concat(res.data.data);
  797. dingdanData.yiFukuan.loading = false;
  798. }
  799. if (code == 0) {
  800. if (res.data.total > dingdanData.quanbu.list.length) {
  801. // 数学
  802. dingdanData.quanbu.state = 'more';
  803. dingdanData.quanbu.state_text = '加载更多';
  804. dingdanData.quanbu.loading = false;
  805. } else {
  806. // 数学
  807. dingdanData.quanbu.state = 'no-more';
  808. dingdanData.quanbu.state_text = '没有更多啦';
  809. dingdanData.quanbu.loading = false;
  810. }
  811. } else if (code == 1) {
  812. if (res.data.total > dingdanData.daiFukuan.list.length) {
  813. // 英语
  814. dingdanData.daiFukuan.state = 'more';
  815. dingdanData.daiFukuan.state_text = '加载更多';
  816. dingdanData.daiFukuan.loading = false;
  817. } else {
  818. // 英语
  819. dingdanData.daiFukuan.state = 'no-more';
  820. dingdanData.daiFukuan.state_text = '没有更多啦';
  821. dingdanData.daiFukuan.loading = false;
  822. }
  823. } else if (code == 2) {
  824. if (res.data.total > dingdanData.yiFukuan.list.length) {
  825. // 英语
  826. dingdanData.yiFukuan.state = 'more';
  827. dingdanData.yiFukuan.state_text = '加载更多';
  828. dingdanData.yiFukuan.loading = false;
  829. } else {
  830. // 英语
  831. dingdanData.yiFukuan.state = 'no-more';
  832. dingdanData.yiFukuan.state_text = '没有更多啦';
  833. dingdanData.yiFukuan.loading = false;
  834. }
  835. }
  836. }).catch(err => {
  837. if (code == 0) {
  838. // 数学
  839. dingdanData.quanbu.state = 'more';
  840. dingdanData.quanbu.state_text = '加载更多';
  841. dingdanData.quanbu.loading = false;
  842. } else if (code == 1) {
  843. // 英语
  844. dingdanData.daiFukuan.state = 'more';
  845. dingdanData.daiFukuan.state_text = '加载更多';
  846. dingdanData.daiFukuan.loading = false;
  847. } else if (code == 2) {
  848. // 英语
  849. dingdanData.yiFukuan.state = 'more';
  850. dingdanData.yiFukuan.state_text = '加载更多';
  851. dingdanData.yiFukuan.loading = false;
  852. }
  853. })
  854. }
  855. function goBack() {
  856. uni.redirectTo({
  857. url: '/pages/my/index'
  858. })
  859. }
  860. const isIOSorAndroid = () => {
  861. const systemInfo = uni.getSystemInfoSync();
  862. console.log('systemInfo', systemInfo);
  863. if (systemInfo.platform == 'ios') {
  864. return currentPlatform.value = 'ios'
  865. } else {
  866. return currentPlatform.value = 'android'
  867. }
  868. }
  869. onLoad((options) => {
  870. dingdanData.current = Number(options.status) || dingdanData.current
  871. getMore(dingdanData.current);
  872. // isIOSorAndroid()
  873. })
  874. </script>
  875. <style>
  876. </style>