order.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="wrap">
  3. <u-navbar title="礼品订单" :placeholder="true" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  4. <view class="filter-box">
  5. <view class="b-item" v-for="(item, index) in groupList" :key="index" :class="[{ 'f-active': index == groupIndex }]" @click="onGroupSelect(index)">
  6. <view class="s-tit">{{ item.name }}</view>
  7. </view>
  8. </view>
  9. <view class="gift-list" v-if="state.items.length > 0">
  10. <view class="b-item" v-for="(item, index) in state.items" :key="index">
  11. <view class="b-head">
  12. <view class="s-order">订单编号:{{ item.number }}</view>
  13. <view class="s-status" :class="[stateStyle(item.status)]">{{ item.status_text }}</view>
  14. </view>
  15. <view class="b-gift" @click="onRecordDetail(item.id)">
  16. <view class="b-left">
  17. <image :src="item.gift_data.cover_url" mode="aspectFill"></image>
  18. </view>
  19. <view class="b-main">
  20. <view class="b-title">{{ item.gift_data.name }}</view>
  21. <view class="b-spec" v-if="item.gift_data.spec_data">
  22. <view class="s-tit">规格:</view>
  23. <view class="s-value">{{ item.gift_data.spec_data.name }}</view>
  24. </view>
  25. <view class="b-fund">
  26. <view class="s-worth" v-if="item.gift_data.order_worth">价值 {{ item.gift_data.order_worth }}元</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="b-foot">
  31. <view class="s-time">兑换时间:{{ timeFormat(item.created_at) }}</view>
  32. </view>
  33. <view class="b-action">
  34. <view class="b-btn" @click="onRecordDetail(item.id)">订单详情</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 加载中 -->
  39. <load-more :loadingType="loadingType" :loadingText="loadingText" color="#888888"></load-more>
  40. <view class="navbar">
  41. <view class="b-action">
  42. <view class="s-home" @click="onHome()">回到奖品首页</view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { getOrderList } from '@/service/api/gift.js';
  49. import Util from '../../common/util';
  50. // import mixinsCommon from '@/mixins/common.js';
  51. // import mixinsAuth from '../../mixins/auth.js';
  52. // import loadMore from '@/components/load-more/load-more.vue';
  53. export default {
  54. // mixins: [mixinsCommon],
  55. data() {
  56. return {
  57. hasLoad: false,
  58. refreshTime: 0,
  59. groupIndex: 0,
  60. groupList: [
  61. {
  62. name: '全部',
  63. value: 0
  64. },
  65. {
  66. name: '待发货',
  67. value: 1
  68. },
  69. {
  70. name: '已发货',
  71. value: 2
  72. },
  73. {
  74. name: '已取消',
  75. value: 3
  76. }
  77. ],
  78. state: {
  79. items: []
  80. },
  81. loadingType: 1,
  82. loadingText: ''
  83. };
  84. },
  85. onLoad(options) {
  86. this.loadOrderList(true);
  87. },
  88. onShow() {
  89. if (this.hasLoad) {
  90. const timestamp = Util.getTimestamp();
  91. if (timestamp - this.refreshTime >= 10) {
  92. this.refreshTime = timestamp;
  93. this.loadOrderList(true);
  94. }
  95. }
  96. },
  97. onReachBottom() {
  98. if (this.loadingType !== 1 && this.loadingType !== 2) {
  99. this.loadOrderList();
  100. }
  101. },
  102. computed: {
  103. stateStyle() {
  104. return (status) => {
  105. return {
  106. 'f-wait': status === 1,
  107. 'f-done': status === 2,
  108. 'f-cancel': status === 3
  109. };
  110. };
  111. }
  112. },
  113. methods: {
  114. loadOrderList(refresh) {
  115. console.log('loadOrderList', refresh);
  116. if (refresh) {
  117. this.page = 1;
  118. this.state.items = [];
  119. } else {
  120. this.page++;
  121. }
  122. this.loadingType = 1;
  123. this.loadingText = '';
  124. getOrderList(this.groupList[this.groupIndex].value, this.page, 10).then(([err, res]) => {
  125. console.log('getList', err, res);
  126. this.loadingType = -1;
  127. this.hasLoad = true;
  128. if (!err) {
  129. if (res.items.length > 0) {
  130. this.state.items = [...this.state.items, ...res.items];
  131. } else {
  132. this.loadingType = 2;
  133. if (this.page == 1) {
  134. this.loadingText = '暂无订单';
  135. }
  136. this.page--; // 重置分页
  137. }
  138. } else {
  139. this.loadingType = 3;
  140. }
  141. });
  142. },
  143. onGroupSelect(index) {
  144. this.groupIndex = index;
  145. this.loadOrderList(true);
  146. },
  147. onRecordDetail(recordId) {
  148. uni.navigateTo({
  149. url: '/answer_pages/gift/order_detail?id=' + recordId
  150. });
  151. },
  152. onHome() {
  153. uni.navigateTo({
  154. url: '/answer_pages/gift/index'
  155. });
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. // page {
  162. // padding-bottom: env(safe-area-inset-bottom);
  163. // background: $pq-bg-color;
  164. // }
  165. .wrap {
  166. padding-bottom: 50upx;
  167. }
  168. .filter-box {
  169. padding: 30upx 50upx 0 50upx;
  170. margin-bottom: 30upx;
  171. background: #fff;
  172. // border-bottom: 1upx solid #eee;
  173. display: flex;
  174. align-items: center;
  175. .b-item {
  176. margin: 0 40upx;
  177. height: 80upx;
  178. line-height: 80upx;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. font-size: 30upx;
  183. padding-bottom: 6upx;
  184. &.f-active {
  185. padding-bottom: 0;
  186. border-bottom: 6upx solid #da5650;
  187. .s-tit {
  188. color: #da5650;
  189. }
  190. }
  191. .s-tit {
  192. color: #333;
  193. }
  194. }
  195. }
  196. .gift-list {
  197. .b-item {
  198. background: #fff;
  199. margin-bottom: 30upx;
  200. &:last-child {
  201. margin-bottom: 0;
  202. }
  203. .b-head {
  204. padding: 20upx 30upx;
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. border-bottom: 1upx solid #eee;
  209. .s-order {
  210. color: #666;
  211. font-size: 26upx;
  212. }
  213. .s-status {
  214. font-size: 28upx;
  215. &.f-wait {
  216. color: #ffc300;
  217. }
  218. &.f-done {
  219. color: #da5650;
  220. }
  221. &.f-cancel {
  222. color: #666;
  223. }
  224. }
  225. }
  226. .b-gift {
  227. padding: 30upx;
  228. display: flex;
  229. border-bottom: 1upx solid #eee;
  230. .b-left {
  231. width: 160upx;
  232. height: 160upx;
  233. image {
  234. width: 160upx;
  235. height: 160upx;
  236. }
  237. }
  238. .b-main {
  239. margin-left: 30upx;
  240. flex: 1;
  241. display: flex;
  242. flex-direction: column;
  243. .b-title {
  244. font-size: 28upx;
  245. color: #333;
  246. }
  247. .b-spec {
  248. margin-top: 20upx;
  249. display: flex;
  250. align-items: center;
  251. .s-tit {
  252. font-size: 24upx;
  253. color: #999;
  254. }
  255. .s-value {
  256. margin-left: 10upx;
  257. font-size: 24upx;
  258. color: #666;
  259. }
  260. }
  261. .b-fund {
  262. margin-top: 20upx;
  263. display: flex;
  264. align-items: baseline;
  265. .s-worth {
  266. font-size: 24upx;
  267. color: #999;
  268. }
  269. }
  270. }
  271. }
  272. .b-foot {
  273. padding: 20upx 30upx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: space-between;
  277. .s-time {
  278. color: #999;
  279. font-size: 26upx;
  280. }
  281. }
  282. .b-action {
  283. padding: 20upx 30upx 40upx 30upx;
  284. display: flex;
  285. align-items: center;
  286. justify-content: flex-end;
  287. .b-btn {
  288. padding: 0 20upx;
  289. border: 1upx solid #bbb;
  290. color: #666;
  291. font-size: 26upx;
  292. line-height: 60upx;
  293. height: 60upx;
  294. border-radius: 10upx;
  295. }
  296. }
  297. }
  298. }
  299. .navbar {
  300. position: fixed;
  301. left: 0;
  302. bottom: 0;
  303. width: 100%;
  304. height: 100upx;
  305. background: #fff;
  306. // border-top: 1upx solid #f6f6f6;
  307. display: flex;
  308. align-items: center;
  309. justify-content: space-between;
  310. .b-action {
  311. flex: 1;
  312. .s-home {
  313. background: #da5650;
  314. height: 100upx;
  315. padding: 0 60upx;
  316. line-height: 100upx;
  317. font-size: 30upx;
  318. color: #fff;
  319. letter-spacing: 4upx;
  320. text-align: center;
  321. }
  322. }
  323. }
  324. </style>