index.vue 14 KB

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