order.vue 27 KB

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