order.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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. getOrderList,
  243. orderInfo,
  244. orderAdd
  245. } from "@/api/order";
  246. import {
  247. onLoad
  248. } from "@dcloudio/uni-app";
  249. import {
  250. toast,
  251. debounce,
  252. getUserIdentity
  253. } from "@/utils/common";
  254. import cacheManager from '@/utils/cacheManager.js';
  255. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  256. import payComponents from '@/components/payComponents/index.vue';
  257. import productDialog from './productDialog.vue'
  258. const mallProductPopup = ref(null);
  259. const payComponentsRef = ref(null);
  260. const showPayWay = ref(true)
  261. let currentPlatform = ref('android')
  262. const payType = ref('weixin');
  263. let orderId = ref('');
  264. let productId = ref(null)
  265. let iapChannel = ref(null)
  266. let quantity = ref(1)
  267. let channel = ref('')
  268. let appleFlag = ref('')
  269. function switchPayWay() {
  270. payType.value = payType.value == 'weixin' ? 'zhifubao' : 'weixin'
  271. }
  272. function detailBtn(data, index) {
  273. mallProductPopup.value.detailShow(data.levelList);
  274. }
  275. const dingdanData = reactive({
  276. items: ['全部', '待付款', '已付款'],
  277. current: 0,
  278. quanbu: {
  279. page: 0,
  280. list: [],
  281. loading: false,
  282. state: 'more',
  283. contentText: {
  284. contentdown: '查看更多',
  285. contentrefresh: '加载中',
  286. contentnomore: '没有更多'
  287. }
  288. },
  289. daiFukuan: {
  290. page: 0,
  291. list: [],
  292. loading: false,
  293. state: 'more',
  294. contentText: {
  295. contentdown: '查看更多',
  296. contentrefresh: '加载中',
  297. contentnomore: '没有更多'
  298. }
  299. },
  300. yiFukuan: {
  301. page: 0,
  302. list: [],
  303. loading: false,
  304. state: 'more',
  305. contentText: {
  306. contentdown: '查看更多',
  307. contentrefresh: '加载中',
  308. contentnomore: '没有更多'
  309. }
  310. },
  311. })
  312. function goDao(data,index){
  313. console.log('data',data);
  314. console.log('index',index);
  315. if(data.type ==0 &&data.levelList.length ==1){
  316. cacheManager.updateObject('auth', {
  317. typeId: data.levelList[0].typeId,
  318. levelId: data.levelList[0].levelId,
  319. subjectId: data.levelList[0].subjectId,
  320. currentZhang: 0
  321. })
  322. cacheManager.remove('daoPageCache')
  323. uni.redirectTo({
  324. url: `/pages/study/index`
  325. })
  326. }
  327. }
  328. function genggaiVip(data) {
  329. uni.hideLoading();
  330. const localList = cacheManager.get('auth').levelIdList || []
  331. const mergeList = [...new Set([...localList, ...data.levelIdList])]
  332. cacheManager.updateObject('auth', {
  333. levelIdList: mergeList
  334. })
  335. toast("支付成功")
  336. dingdanData.current = 2
  337. getMore(2)
  338. // if (formPage.value == 'my') {
  339. // uni.redirectTo({
  340. // url: '/pages/my/index'
  341. // })
  342. // } else {
  343. // uni.redirectTo({
  344. // url: '/pages/study/index'
  345. // })
  346. // }
  347. }
  348. const creatOrderIos = debounce((data, index) => {
  349. uni.showLoading({
  350. title: '',
  351. mask: true
  352. });
  353. if (appleFlag.value.toString() == 'true') {
  354. productId.value = 'llisoftEzhuangyuanceshi'
  355. } else {
  356. if (cardId.value == 1) {
  357. productId.value = 'llisoftEzhuangyuan'
  358. } else {
  359. productId.value = 'llisoftEzhuangyuanYingyu'
  360. }
  361. }
  362. uni.hideLoading();
  363. orderId.value = data.id
  364. // 测试ios 1元
  365. applePay()
  366. }, 500)
  367. function applePaySuccess(data) {
  368. uni.showLoading({
  369. title: '开通中',
  370. mask: true
  371. });
  372. let req = {
  373. "id": orderId.value,
  374. "paynum": data.transactionIdentifier,
  375. "receipt": data.transactionReceipt
  376. }
  377. console.log('reqreq', req);
  378. orderPayApple(req).then(res => {
  379. if (res.code == 0 && res.data) {
  380. iapChannel.finishTransaction(data.transactionIdentifier)
  381. console.log('resiapChanneliapChanneliapChannel', res);
  382. orderCheck({
  383. id: orderId.value
  384. }).then(res3 => {
  385. console.log('res3', res3);
  386. if (res3.code == 0) {
  387. genggaiVip(res3.data)
  388. } else {
  389. setTimeout(() => {
  390. orderCheck({
  391. id: orderId.value
  392. }).then(res4 => {
  393. if (res4.code == 0) {
  394. genggaiVip(res4.data)
  395. } else {
  396. toast(
  397. "开通失败,请联系管理员!"
  398. )
  399. uni
  400. .hideLoading();
  401. return false
  402. }
  403. }).catch(() => {
  404. uni.hideLoading();
  405. toast("check接口报错")
  406. return false
  407. })
  408. }, 5000)
  409. }
  410. }).catch(() => {
  411. uni.hideLoading();
  412. toast("check接口报错")
  413. return false
  414. })
  415. } else {
  416. iapChannel.finishTransaction(data.transactionIdentifier)
  417. uni.hideLoading();
  418. toast("苹果内购失败")
  419. console.log('orderPayApple失败');
  420. return false
  421. }
  422. })
  423. }
  424. function applePay() {
  425. console.log('123123');
  426. if (!productId.value) {
  427. uni.showToast({
  428. title: '苹果内购ID缺失,请选择其它支付方式或联系客服',
  429. icon: "none"
  430. });
  431. return false;
  432. }
  433. uni.showLoading({
  434. title: '正在支付中...'
  435. });
  436. try {
  437. plus.payment.getChannels(function(channels) { //判读项目支付通道开通情况
  438. for (var i in channels) {
  439. iapChannel = channels[i];
  440. // 获取 id 为 'appleiap' 的 channel
  441. console.info("支付通道", iapChannel)
  442. if (iapChannel.id === 'appleiap') { //开通了app应用内支付,在manifest.josn中设置,开通后需打自定议基座
  443. console.info("苹果支付通道", iapChannel)
  444. // ids 数组中的项为 App Store Connect 配置的内购买项目产品ID(productId)
  445. var ids = [productId.value];
  446. // iap 为应用内支付对象
  447. iapChannel.requestOrder(ids, function(e) {
  448. // 获取订单信息成功回调方法
  449. console.log('requestOrder success: ' + JSON.stringify(e));
  450. uni.requestPayment({
  451. provider: 'appleiap',
  452. orderInfo: {
  453. productid: productId.value, //产品id,来自于苹果
  454. quantity: quantity.value, //产品数量
  455. manualFinishTransaction: true
  456. },
  457. success: (e) => {
  458. uni.hideLoading();
  459. // toast("苹果内购成功")
  460. console.info("苹果内购成功", e)
  461. applePaySuccess(e)
  462. //e.payment.orderNo = that.orderNo
  463. //支付成功回调,前端调用后台接口
  464. },
  465. fail: (e) => {
  466. uni.hideLoading();
  467. toast("苹果内购失败")
  468. console.info("苹果内购失败", e)
  469. },
  470. })
  471. },
  472. function(e) {
  473. // 获取订单信息失败回调方法
  474. console.log('requestOrder failed: ' + JSON.stringify(e));
  475. });
  476. } else {
  477. console.log('不支持苹果支付')
  478. }
  479. }
  480. },
  481. function(e) {
  482. console.log("获取iap支付通道失败:" + e.message);
  483. });
  484. } catch (e) {
  485. uni.showModal({
  486. title: "init",
  487. content: e.message,
  488. showCancel: false
  489. });
  490. } finally {
  491. uni.hideLoading();
  492. }
  493. }
  494. function wxPay() {
  495. orderPayWx({
  496. id: orderId.value
  497. }).then(res2 => {
  498. uni.hideLoading();
  499. console.log('res2', res2);
  500. if(res2.code !=0){
  501. return false
  502. }
  503. uni.requestPayment({
  504. "provider": "wxpay",
  505. "orderInfo": {
  506. "appid": res2.data.appid, // 应用ID(AppID)
  507. "partnerid": res2.data.partnerId, // 商户号(PartnerID)
  508. "prepayid": res2.data.prepayId, // 预支付交易会话ID
  509. "package": res2.data.packageVal, // 固定值
  510. "noncestr": res2.data.nonceStr, // 随机字符串
  511. "timestamp": res2.data.timestamp, // 时间戳(单位:秒)
  512. "sign": res2.data.sign // 签名,这里用的 MD5 签名
  513. }, //此处为服务器返回的订单信息字符串
  514. success: function(res) {
  515. //var rawdata = JSON.parse(res.rawdata);
  516. // console.log('res',res);
  517. // console.log('支付成功');
  518. // console.log('rawdata', rawdata);
  519. uni.showLoading({
  520. title: '开通中,请稍后...'
  521. });
  522. orderCheck({
  523. id: orderId.value
  524. }).then(res3 => {
  525. console.log('res3', res3);
  526. if (res3.code == 0) {
  527. genggaiVip(res3.data)
  528. } else {
  529. setTimeout(() => {
  530. orderCheck({
  531. id: orderId.value
  532. }).then(res4 => {
  533. if (res4.code == 0) {
  534. genggaiVip(res4.data)
  535. } else {
  536. toast(
  537. "开通失败,请联系管理员!"
  538. )
  539. uni
  540. .hideLoading();
  541. return false
  542. }
  543. }).catch(() => {
  544. uni.hideLoading();
  545. toast("check接口报错")
  546. return false
  547. })
  548. }, 5000)
  549. }
  550. }).catch(() => {
  551. uni.hideLoading();
  552. toast("check接口报错")
  553. return false
  554. })
  555. },
  556. fail: function(err) {
  557. uni.hideLoading();
  558. // toast('支付失败:' + JSON.stringify(err));
  559. console.log('支付失败:' + JSON.stringify(err));
  560. }
  561. });
  562. }).catch((error) => {
  563. uni.hideLoading();
  564. console.log(error);
  565. })
  566. }
  567. function aliApy() {
  568. orderPayAli({
  569. id: orderId.value
  570. }).then(res2 => {
  571. console.log('res2', res2);
  572. uni.hideLoading();
  573. if(res2.code !=0){
  574. return false
  575. }
  576. uni.requestPayment({
  577. "provider": "alipay",
  578. "orderInfo": res2.data.text, //此处为服务器返回的订单信息字符串
  579. success: function(res) {
  580. // var rawdata = JSON.parse(res.rawdata);
  581. // console.log('支付成功');
  582. // console.log('rawdata', rawdata);
  583. uni.showLoading({
  584. title: '开通中,请稍后...'
  585. });
  586. orderCheck({
  587. id: orderId.value
  588. }).then(res3 => {
  589. if (res3.code == 0) {
  590. genggaiVip(res3.data)
  591. } else {
  592. setTimeout(() => {
  593. orderCheck({
  594. id: orderId.value
  595. }).then(res4 => {
  596. if (res4.code ==
  597. 0) {
  598. genggaiVip(res4.data)
  599. } else {
  600. toast(
  601. "开通失败,请联系管理员!"
  602. )
  603. uni
  604. .hideLoading();
  605. return false
  606. }
  607. }).catch(() => {
  608. uni.hideLoading();
  609. toast("check接口报错")
  610. return false
  611. })
  612. }, 5000)
  613. }
  614. }).catch(() => {
  615. uni.hideLoading();
  616. toast("check接口报错")
  617. return false
  618. })
  619. },
  620. fail: function(err) {
  621. console.log('支付失败:' + JSON.stringify(err));
  622. uni.hideLoading();
  623. }
  624. });
  625. })
  626. }
  627. const creatOrder = debounce((data, index) => {
  628. uni.showLoading({
  629. title: '',
  630. mask: true
  631. });
  632. if (payType.value == 'weixin') {
  633. orderId.value = data.id
  634. wxPay()
  635. } else {
  636. orderId.value = data.id
  637. aliApy()
  638. }
  639. }, 500)
  640. function onChangeTab(e) {
  641. if (dingdanData.current !== e.currentIndex) {
  642. dingdanData.current = e.currentIndex;
  643. if (dingdanData.current == 0) {
  644. dingdanData.quanbu.page = 0
  645. } else if (dingdanData.current == 1) {
  646. dingdanData.daiFukuan.page = 0
  647. } else if (dingdanData.current == 2) {
  648. dingdanData.yiFukuan.page = 0
  649. }
  650. refreshData(dingdanData.current);
  651. }
  652. }
  653. function onScrolltolower() {
  654. getMore(dingdanData.current)
  655. }
  656. function refreshData(code) {
  657. const opt = {
  658. page: 1,
  659. size: 10, // 固定查询10条
  660. status: code
  661. }
  662. if (code == 0) {
  663. dingdanData.quanbu.list = [];
  664. // 数学
  665. dingdanData.quanbu.state = 'loading';
  666. dingdanData.quanbu.page++;
  667. opt.page = dingdanData.quanbu.page;
  668. } else if (code == 1) {
  669. dingdanData.daiFukuan.list = [];
  670. // 英语
  671. dingdanData.daiFukuan.state = 'loading';
  672. dingdanData.daiFukuan.page++;
  673. opt.page = dingdanData.daiFukuan.page;
  674. } else if (code == 2) {
  675. dingdanData.yiFukuan.list = [];
  676. // 英语
  677. dingdanData.yiFukuan.state = 'loading';
  678. dingdanData.yiFukuan.page++;
  679. opt.page = dingdanData.yiFukuan.page;
  680. }
  681. getOrderList(opt).then(res => {
  682. if (code == 0) {
  683. dingdanData.quanbu.list = dingdanData.quanbu.list.concat(res.data.data);
  684. dingdanData.quanbu.loading = false;
  685. } else if (code == 1) {
  686. dingdanData.daiFukuan.list = dingdanData.daiFukuan.list.concat(res.data.data);
  687. dingdanData.daiFukuan.loading = false;
  688. } else if (code == 2) {
  689. dingdanData.yiFukuan.list = dingdanData.yiFukuan.list.concat(res.data.data);
  690. dingdanData.yiFukuan.loading = false;
  691. }
  692. if (code == 0) {
  693. if (res.data.total > dingdanData.quanbu.list.length) {
  694. // 数学
  695. dingdanData.quanbu.state = 'more';
  696. dingdanData.quanbu.loading = false;
  697. } else {
  698. // 数学
  699. dingdanData.quanbu.state = 'no-more';
  700. dingdanData.quanbu.loading = false;
  701. }
  702. } else if (code == 1) {
  703. if (res.data.total > dingdanData.daiFukuan.list.length) {
  704. // 英语
  705. dingdanData.daiFukuan.state = 'more';
  706. dingdanData.daiFukuan.loading = false;
  707. } else {
  708. // 英语
  709. dingdanData.daiFukuan.state = 'no-more';
  710. dingdanData.daiFukuan.loading = false;
  711. }
  712. } else if (code == 2) {
  713. if (res.data.total > dingdanData.yiFukuan.list.length) {
  714. // 英语
  715. dingdanData.yiFukuan.state = 'more';
  716. dingdanData.yiFukuan.loading = false;
  717. } else {
  718. // 英语
  719. dingdanData.yiFukuan.state = 'no-more';
  720. dingdanData.yiFukuan.loading = false;
  721. }
  722. }
  723. }).catch(err => {
  724. if (code == 0) {
  725. // 数学
  726. dingdanData.quanbu.state = 'more';
  727. dingdanData.quanbu.loading = false;
  728. } else if (code == 1) {
  729. // 英语
  730. dingdanData.daiFukuan.state = 'more';
  731. dingdanData.daiFukuan.loading = false;
  732. } else if (code == 2) {
  733. // 英语
  734. dingdanData.yiFukuan.state = 'more';
  735. dingdanData.yiFukuan.loading = false;
  736. }
  737. })
  738. }
  739. function onRefresh() {
  740. if (dingdanData.current == 0) {
  741. dingdanData.quanbu.page = 0;
  742. dingdanData.quanbu.list = [];
  743. dingdanData.quanbu.loading = true;
  744. } else if (dingdanData.current == 1) {
  745. dingdanData.daiFukuan.page = 0;
  746. dingdanData.daiFukuan.list = [];
  747. dingdanData.daiFukuan.loading = true;
  748. } else if (dingdanData.current == 2) {
  749. dingdanData.yiFukuan.page = 0;
  750. dingdanData.yiFukuan.list = [];
  751. dingdanData.yiFukuan.loading = true;
  752. }
  753. refreshData(dingdanData.current);
  754. }
  755. function getMore(code) {
  756. const opt = {
  757. page: 1,
  758. size: 10, // 固定查询10条
  759. status: Number(code) // 前台索引加1为学科cardId
  760. }
  761. if (code == 0) {
  762. if (dingdanData.quanbu.state == 'no-more') {
  763. return;
  764. }
  765. // 数学
  766. dingdanData.quanbu.state = 'loading';
  767. dingdanData.quanbu.page++;
  768. opt.page = dingdanData.quanbu.page;
  769. } else if (code == 1) {
  770. if (dingdanData.daiFukuan.state == 'no-more') {
  771. return;
  772. }
  773. dingdanData.daiFukuan.state = 'loading';
  774. dingdanData.daiFukuan.page++;
  775. opt.page = dingdanData.daiFukuan.page;
  776. } else if (code == 2) {
  777. if (dingdanData.yiFukuan.state == 'no-more') {
  778. return;
  779. }
  780. dingdanData.yiFukuan.state = 'loading';
  781. dingdanData.yiFukuan.page++;
  782. opt.page = dingdanData.yiFukuan.page;
  783. }
  784. getOrderList(opt).then(res => {
  785. if (code == 0) {
  786. dingdanData.quanbu.list = dingdanData.quanbu.list.concat(res.data.data);
  787. dingdanData.quanbu.loading = false;
  788. } else if (code == 1) {
  789. dingdanData.daiFukuan.list = dingdanData.daiFukuan.list.concat(res.data.data);
  790. dingdanData.daiFukuan.loading = false;
  791. } else if (code == 2) {
  792. dingdanData.yiFukuan.list = dingdanData.yiFukuan.list.concat(res.data.data);
  793. dingdanData.yiFukuan.loading = false;
  794. }
  795. if (code == 0) {
  796. if (res.data.total > dingdanData.quanbu.list.length) {
  797. // 数学
  798. dingdanData.quanbu.state = 'more';
  799. dingdanData.quanbu.state_text = '加载更多';
  800. dingdanData.quanbu.loading = false;
  801. } else {
  802. // 数学
  803. dingdanData.quanbu.state = 'no-more';
  804. dingdanData.quanbu.state_text = '没有更多啦';
  805. dingdanData.quanbu.loading = false;
  806. }
  807. } else if (code == 1) {
  808. if (res.data.total > dingdanData.daiFukuan.list.length) {
  809. // 英语
  810. dingdanData.daiFukuan.state = 'more';
  811. dingdanData.daiFukuan.state_text = '加载更多';
  812. dingdanData.daiFukuan.loading = false;
  813. } else {
  814. // 英语
  815. dingdanData.daiFukuan.state = 'no-more';
  816. dingdanData.daiFukuan.state_text = '没有更多啦';
  817. dingdanData.daiFukuan.loading = false;
  818. }
  819. } else if (code == 2) {
  820. if (res.data.total > dingdanData.yiFukuan.list.length) {
  821. // 英语
  822. dingdanData.yiFukuan.state = 'more';
  823. dingdanData.yiFukuan.state_text = '加载更多';
  824. dingdanData.yiFukuan.loading = false;
  825. } else {
  826. // 英语
  827. dingdanData.yiFukuan.state = 'no-more';
  828. dingdanData.yiFukuan.state_text = '没有更多啦';
  829. dingdanData.yiFukuan.loading = false;
  830. }
  831. }
  832. }).catch(err => {
  833. if (code == 0) {
  834. // 数学
  835. dingdanData.quanbu.state = 'more';
  836. dingdanData.quanbu.state_text = '加载更多';
  837. dingdanData.quanbu.loading = false;
  838. } else if (code == 1) {
  839. // 英语
  840. dingdanData.daiFukuan.state = 'more';
  841. dingdanData.daiFukuan.state_text = '加载更多';
  842. dingdanData.daiFukuan.loading = false;
  843. } else if (code == 2) {
  844. // 英语
  845. dingdanData.yiFukuan.state = 'more';
  846. dingdanData.yiFukuan.state_text = '加载更多';
  847. dingdanData.yiFukuan.loading = false;
  848. }
  849. })
  850. }
  851. function goBack() {
  852. uni.redirectTo({
  853. url: '/pages/my/index'
  854. })
  855. }
  856. const isIOSorAndroid = () => {
  857. const systemInfo = uni.getSystemInfoSync();
  858. console.log('systemInfo', systemInfo);
  859. if (systemInfo.platform == 'ios') {
  860. return currentPlatform.value = 'ios'
  861. } else {
  862. return currentPlatform.value = 'android'
  863. }
  864. }
  865. onLoad((options) => {
  866. dingdanData.current = Number(options.status) || dingdanData.current
  867. getMore(dingdanData.current);
  868. // isIOSorAndroid()
  869. })
  870. </script>
  871. <style>
  872. </style>