order.vue 27 KB

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