index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <!-- 用户购买 - 订单 -->
  3. <view class="container" :style="appThemeStyle">
  4. <mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{native: true}" @down="downCallback"
  5. :up="upOption" @up="upCallback">
  6. <!-- tab栏 -->
  7. <u-tabs :list="tabs" :is-scroll="false" v-model="curTab" :active-color="appTheme.mainBg" :duration="0.2"
  8. @change="onChangeTab" />
  9. <!-- 订单列表 -->
  10. <view class="order-list">
  11. <!-- l-time-actvied -待激活 -->
  12. <!-- l-time-complete -已经完成 -->
  13. <view class="order-item" :class="{
  14. 'l-time-actvied': item.payordersfkt === 0 && item.payorderstatus == '已支付' && item.payorderlx === '新购',
  15. 'l-time-complete': item.payordersfkt === 1 && item.payorderstatus == '已支付' && item.payorderlx === '新购',
  16. 'l-xufei-order': item.payorderlx === '续费'
  17. }" v-for="(item, index) in list.data" :key="index">
  18. <view>
  19. <view class="item-top">
  20. <view class="item-top-left">
  21. <text class="order-time">{{ item.payordercreatedate }}</text>
  22. </view>
  23. <view class="item-top-right">
  24. <text class="state-text">{{ item.payorderstatus }}</text>
  25. </view>
  26. </view>
  27. <!-- 订单类型 -->
  28. <view class="order-total" style="text-align: left">
  29. <text v-if="item.payorderlx === '新购'"
  30. style="font-size: 30rpx; font-weight: 900; color: #fa2209">{{ item.payorderlx }}订单</text>
  31. <text v-if="item.payorderlx === '续费'"
  32. style="font-size: 30rpx; font-weight: 900; color: #4caf50">{{ item.payorderlx }}订单</text>
  33. <br />
  34. <text>产品:{{ item.payorderproductname }} - </text>
  35. <text>{{ item.payorderproductlimit }} </text>
  36. <text>{{ item.payorderproductlimittype }} </text> <br />
  37. <text>支付:{{ item.payorderpaytitle }}</text> <br />
  38. <text>企业码:{{ item.payorderqym }}</text> <br />
  39. </view>
  40. <!-- 订单合计 -->
  41. <view class="order-total" style="text-align: left">
  42. <text>共 1 件商品,总金额 </text>
  43. <text class="unit">¥</text>
  44. <text class="money">{{ item.payorderprice }}</text>
  45. </view>
  46. <!-- 实名激活状态弹窗 -->
  47. <view class="actvied-center" v-if="userInfoData.customersfrz === 0">
  48. <text class="actvied-t1">此订单已经完成支付,产品待激活,根据国家工信部实名制要求,请根据提示完成实名认证后激活此产品服务。</text>
  49. </view>
  50. <!-- 已实名 待绑定手机号码 状态弹窗 -->
  51. <view class="actvied-center" v-if="userInfoData.customersfrz === 1">
  52. <text class="actvied-t1">此订单已经完成支付,产品待激活,根据国家工信部实名制要求,请根据提示完成实名认证后激活此产品服务。</text>
  53. </view>
  54. <!-- 已经完成 -->
  55. <view class="complete-center">
  56. <text class="actvied-t1">此订单已经激活,请注意查收产品账户密码,信飞通会通过绑定的手机号码进行发送</text>
  57. </view>
  58. <!-- 续费资费 -->
  59. <view class="" v-if="item.payorderzfsfsx == 0 && item.payorderlx === '续费'">
  60. <text class="actvied-t1" style="color: #4caf50">当前资费到期后自动入账</text>
  61. </view>
  62. <!-- 订单号 -->
  63. <view class="order-total" style="text-align: left">
  64. <!-- <text class="order-time">账号状态:{{ item.payordersfkt ? '已经激活' : '待激活' }}</text><br /> -->
  65. <text class="order-time">订单号:{{ item.payorderproductid }}</text> <br />
  66. </view>
  67. <!-- 订单操作 -->
  68. <view class="order-handle">
  69. <view class="btn-group clearfix">
  70. <!-- 未支付的订单 -->
  71. <view v-if="userInfoData.customersfrz === 0" class="btn-item redbt actviedbt"
  72. @click="handleService('pages/user/activatorder/index', item)">立刻实名认证</view>
  73. <view v-if="userInfoData.customersfrz === 1" class="btn-item redbt actviedbt"
  74. @click="handleService('pages/user/activatorder/index', item)">立刻绑定手机号</view>
  75. <!-- <view class="btn-item" @click="onCancel(item.order_id)">申请取消</view> -->
  76. <view v-if="item.payorderstatus == '已支付'&&item.payordersfkt==1" class="btn-item redbt"
  77. @click="handleInvoice(item)">查看发票</view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view style="width: 100%; height: 100rpx"> </view>
  83. </view>
  84. </mescroll-body>
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. DeliveryStatusEnum,
  90. DeliveryTypeEnum,
  91. OrderStatusEnum,
  92. PayStatusEnum,
  93. ReceiptStatusEnum
  94. } from '@/common/enum/order'
  95. import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins'
  96. import {
  97. getEmptyPaginateObj,
  98. getMoreListData
  99. } from '@/core/app'
  100. import * as OrderApi from '@/api/order'
  101. import * as AppApi from '@/api/app'
  102. import storage from '@/utils/storage'
  103. // 每页记录数量
  104. const pageSize = 15
  105. // tab栏数据
  106. const tabs = [{
  107. name: `全部`,
  108. value: 'all',
  109. key: ''
  110. },
  111. {
  112. name: `待支付`,
  113. value: 'payment',
  114. key: '待支付'
  115. },
  116. // {
  117. // name: `待发货`,
  118. // value: 'delivery'
  119. // },
  120. // {
  121. // name: `待收货`,
  122. // value: 'received'
  123. // },
  124. {
  125. name: `已支付`,
  126. value: 'comment',
  127. key: '已支付'
  128. }
  129. ]
  130. export default {
  131. mixins: [MescrollMixin],
  132. data() {
  133. return {
  134. // 枚举类
  135. DeliveryStatusEnum,
  136. DeliveryTypeEnum,
  137. OrderStatusEnum,
  138. PayStatusEnum,
  139. ReceiptStatusEnum,
  140. userInfoData: {},
  141. // 当前页面参数
  142. options: {
  143. dataType: 'all'
  144. },
  145. // tab栏数据
  146. tabs,
  147. // 当前标签索引
  148. curTab: 0,
  149. // 订单列表数据
  150. list: getEmptyPaginateObj(),
  151. // 上拉加载配置
  152. upOption: {
  153. // 首次自动执行
  154. auto: true,
  155. // 每页数据的数量; 默认10
  156. page: {
  157. size: pageSize
  158. },
  159. // 数量要大于4条才显示无更多数据
  160. noMoreSize: 4,
  161. // 空布局
  162. empty: {
  163. tip: '亲,暂无订单记录'
  164. }
  165. },
  166. // 控制onShow事件是否刷新订单列表
  167. canReset: false
  168. }
  169. },
  170. /**
  171. * 生命周期函数--监听页面加载
  172. */
  173. onLoad(options) {
  174. // 初始化当前选中的标签
  175. this.initCurTab(options)
  176. // 注册全局事件订阅: 是否刷新订单列表
  177. uni.$on('syncRefresh', (canReset) => {
  178. this.canReset = canReset
  179. })
  180. // 用户信息
  181. this.userInfoData = storage.get('wx_userinfo')
  182. },
  183. /**
  184. * 生命周期函数--监听页面显示
  185. */
  186. onShow() {
  187. this.onRefreshList()
  188. this.canReset = false
  189. },
  190. /**
  191. * 生命周期函数--监听页面的卸载
  192. */
  193. onUnload() {
  194. // 卸载全局事件订阅
  195. uni.$off('syncRefresh')
  196. },
  197. methods: {
  198. // 初始化当前选中的标签
  199. initCurTab(options) {
  200. const app = this
  201. if (options.dataType) {
  202. const index = app.tabs.findIndex((item) => item.value == options.dataType)
  203. app.curTab = index > -1 ? index : 0
  204. }
  205. },
  206. /**
  207. * 上拉加载的回调 (页面初始化时也会执行一次)
  208. * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
  209. * @param {Object} page
  210. */
  211. async upCallback(page) {
  212. const app = this
  213. // 设置列表数据
  214. // 获取支付数据
  215. const params = {
  216. pageindex: page.num,
  217. rows: page.size,
  218. 'payorderopenid.value': storage.get('wx_openid'),
  219. 'payorderstatus.value': this.tabs[app.curTab].key || '',
  220. pagevalue: 299
  221. }
  222. const {
  223. Data: res
  224. } = await AppApi.getPalList(params)
  225. const curPageLen = res.Data.length
  226. const totalSize = res.Total
  227. app.mescroll.endBySize(curPageLen, totalSize)
  228. // const newList = app.initList({data: res.Data})
  229. app.list.data = getMoreListData({
  230. data: res.Data
  231. }, app.list, page.num)
  232. // app
  233. // .getOrderList(page.num)
  234. // .then((list) => {
  235. // const curPageLen = list.data.length
  236. // const totalSize = list.data.total
  237. // app.mescroll.endBySize(curPageLen, totalSize)
  238. // })
  239. // .catch(() => app.mescroll.endErr())
  240. },
  241. // 获取订单列表
  242. getOrderList(pageNo = 1) {
  243. const app = this
  244. console.log('获取订单列表')
  245. // return new Promise((resolve, reject) => {
  246. // OrderApi.list({dataType: app.getTabValue(), page: pageNo}, {load: false}).then((result) => {
  247. // // 合并新数据
  248. // const newList = app.initList(result.data.list)
  249. // app.list.data = getMoreListData(newList, app.list, pageNo)
  250. // resolve(newList)
  251. // })
  252. // })
  253. },
  254. // 初始化订单列表数据
  255. initList(newList) {
  256. newList.data.forEach((item) => {
  257. item.total_num = 0
  258. item.goods.forEach((goods) => {
  259. item.total_num += goods.total_num
  260. })
  261. })
  262. return newList
  263. },
  264. // 获取当前标签项的值
  265. getTabValue() {
  266. return this.tabs[this.curTab].value
  267. },
  268. // 切换标签项
  269. onChangeTab(index) {
  270. const app = this
  271. // 设置当前选中的标签
  272. app.curTab = index
  273. // 刷新订单列表
  274. app.onRefreshList()
  275. },
  276. // 刷新订单列表
  277. onRefreshList() {
  278. console.log('刷新订单列表')
  279. this.list = getEmptyPaginateObj()
  280. setTimeout(() => {
  281. this.mescroll.resetUpScroll()
  282. }, 120)
  283. },
  284. // 取消订单
  285. onCancel(orderId) {
  286. const app = this
  287. uni.showModal({
  288. title: '友情提示',
  289. content: '确认要取消该订单吗?',
  290. success(o) {
  291. if (o.confirm) {
  292. OrderApi.cancel(orderId).then((result) => {
  293. // 显示成功信息
  294. app.$toast(result.message)
  295. // 刷新订单列表
  296. app.onRefreshList()
  297. })
  298. }
  299. }
  300. })
  301. },
  302. // 确认收货
  303. onReceipt(orderId) {
  304. const app = this
  305. uni.showModal({
  306. title: '友情提示',
  307. content: '确认收到商品了吗?',
  308. success(o) {
  309. if (o.confirm) {
  310. OrderApi.receipt(orderId).then((result) => {
  311. // 显示成功信息
  312. app.$success(result.message)
  313. // 刷新订单列表
  314. app.onRefreshList()
  315. })
  316. }
  317. }
  318. })
  319. },
  320. // 跳转到服务页面
  321. handleService(url, item) {
  322. this.$navTo(url, {
  323. payorderid: item.payorderid,
  324. payordercustomerid: item.payordercustomerid
  325. })
  326. },
  327. // 跳转到发票界面
  328. handleInvoice(item) {
  329. this.$navTo('pages/invoice/index', {
  330. payorderid: item.payorderid
  331. })
  332. },
  333. // 点击去支付
  334. onPay(orderId) {
  335. this.$navTo('pages/checkout/cashier/index', {
  336. orderId
  337. })
  338. },
  339. // 跳转到订单详情页
  340. handleTargetDetail(orderId) {
  341. this.$navTo('pages/order/detail', {
  342. orderId
  343. })
  344. },
  345. // 跳转到订单评价页
  346. handleTargetComment(orderId) {
  347. this.$navTo('pages/order/comment/index', {
  348. orderId
  349. })
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. .xufeiorder {}
  356. .l-xufei-order {}
  357. // 待激活
  358. .actvied-center {
  359. display: none;
  360. color: #fa2209;
  361. margin-bottom: 10rpx;
  362. }
  363. .actviedbt {
  364. display: none;
  365. }
  366. .l-time-actvied {
  367. background: #fff2f2 !important;
  368. border: 1px solid #fa2209;
  369. .actvied-center {
  370. display: flex;
  371. }
  372. .actviedbt {
  373. display: block;
  374. }
  375. }
  376. // 已经激活
  377. .complete-center {
  378. display: none;
  379. color: #4caf50;
  380. margin-bottom: 10rpx;
  381. }
  382. .l-time-complete {
  383. border: 1px solid #4caf50;
  384. .complete-center {
  385. display: flex;
  386. }
  387. }
  388. .redbt {
  389. background: #fa2209;
  390. color: #fff !important;
  391. border: none !important;
  392. }
  393. // 项目内容
  394. .order-item {
  395. margin: 20rpx auto 20rpx auto;
  396. padding: 30rpx 30rpx;
  397. width: 94%;
  398. box-shadow: 0 1rpx 5rpx 0px rgba(0, 0, 0, 0.05);
  399. border-radius: 16rpx;
  400. background: #fff;
  401. }
  402. // 项目顶部
  403. .item-top {
  404. display: flex;
  405. justify-content: space-between;
  406. font-size: 26rpx;
  407. margin-bottom: 40rpx;
  408. .order-time {
  409. color: #777;
  410. }
  411. .state-text {
  412. color: $main-bg;
  413. }
  414. }
  415. // 商品列表
  416. .goods-list {
  417. // 商品项
  418. .goods-item {
  419. display: flex;
  420. margin-bottom: 40rpx;
  421. // 商品图片
  422. .goods-image {
  423. width: 180rpx;
  424. height: 180rpx;
  425. .image {
  426. display: block;
  427. width: 100%;
  428. height: 100%;
  429. border-radius: 8rpx;
  430. }
  431. }
  432. // 商品内容
  433. .goods-content {
  434. flex: 1;
  435. padding-left: 16rpx;
  436. padding-top: 16rpx;
  437. .goods-title {
  438. font-size: 26rpx;
  439. max-height: 76rpx;
  440. }
  441. .goods-props {
  442. margin-top: 14rpx;
  443. color: #ababab;
  444. font-size: 24rpx;
  445. overflow: hidden;
  446. .goods-props-item {
  447. padding: 4rpx 16rpx;
  448. border-radius: 12rpx;
  449. background-color: #fcfcfc;
  450. }
  451. }
  452. }
  453. // 交易信息
  454. .goods-trade {
  455. padding-top: 16rpx;
  456. width: 150rpx;
  457. text-align: right;
  458. color: $uni-text-color-grey;
  459. font-size: 26rpx;
  460. .goods-price {
  461. vertical-align: bottom;
  462. margin-bottom: 16rpx;
  463. .unit {
  464. margin-right: -2rpx;
  465. font-size: 24rpx;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. // 订单合计
  472. .order-total {
  473. font-size: 26rpx;
  474. vertical-align: bottom;
  475. text-align: right;
  476. line-height: 50rpx;
  477. .unit {
  478. margin-left: 8rpx;
  479. margin-right: -2rpx;
  480. font-size: 26rpx;
  481. }
  482. .money {
  483. font-size: 28rpx;
  484. }
  485. }
  486. // 订单操作
  487. .order-handle {
  488. .btn-group {
  489. .btn-item {
  490. border-radius: 10rpx;
  491. padding: 8rpx 20rpx;
  492. margin-left: 15rpx;
  493. font-size: 26rpx;
  494. float: right;
  495. color: #383838;
  496. border: 1rpx solid #a8a8a8;
  497. &:last-child {
  498. margin-left: 0;
  499. }
  500. &.active {
  501. color: $main-bg;
  502. border: 1rpx solid $main-bg;
  503. }
  504. }
  505. }
  506. }
  507. </style>