order.vue 28 KB

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