时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
8.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  4. <view class="padding-lr" style="margin-bottom: 10rpx;margin-top: 20rpx;">
  5. <me-tabs v-model="current" :tabs="tab_list" :fixed="true" @change="change"></me-tabs>
  6. <!-- <u-tabs :list="tab_list" :is-scroll="true" :show-bar="false" :current="current" @change="change"></u-tabs> -->
  7. </view>
  8. <view class="com" v-for="(tab, tabIndex) in tab_list" v-if="tabIndex == current" :key="tab.id">
  9. <view class="flex-direction justify-around list" v-for="(item, index) in tab.list" :key="item.id" @tap="goDetails(tabIndex,index)">
  10. <view class="lf-row-between">
  11. <view class="left" style="position: relative;display: flex;">
  12. <image :src="item.goods.cover" mode=""></image>
  13. <view class="cu-tag badge tag-self lf-font-28 font-400" :style="{'background-color':item.state_text.bg_color,'color':item.state_text.color}">{{item.state_text.text}}</view>
  14. </view>
  15. <view class="right">
  16. <view class="lf-line-2 title" style="line-height: 40rpx;">{{item.goods.name}}</view>
  17. <view class="lf-flex tips" style="margin: 0!important;">
  18. <text class="progress margin-right-xs">数量</text>
  19. <text class="bought">x {{item.number}}</text>
  20. </view>
  21. <view class="lf-row-between price" style="padding-right: 6rpx;">
  22. <!-- <text class="lf-font-bold">
  23. <text class="lf-font-24"></text>
  24. <text class="lf-font-42">{{item.selling_price}}</text>
  25. </text> -->
  26. <lf-price :price="item.selling_price" style="margin-top: 10rpx;" />
  27. <button v-if="item.state==1" @tap.stop="$routerGo('/pages/order/confirm-order?type=1&goods_id='+item.goods_id+'&goods_specs_id='+item.goods_specs_id +'&order_id='+ item.id)">立即付款</button>
  28. <button v-if="item.state==2" class="cu-btn bg-green round margin-left-sm" @tap="$routerGo('/pages/order/order-details?order_id='+item.id)">立即使用</button>
  29. <button v-if="item.state==4" class="cu-btn1 border round margin-left-sm">等待审核</button>
  30. </view>
  31. </view>
  32. </view>
  33. <view>
  34. <view class="solid-top flex justify-between align-center text-center">
  35. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  36. {{item.created_at_text}}
  37. </view>
  38. <view class="text-orange" v-if="item.state==1" style="padding: 20rpx 24rpx 20rpx 20rpx;">
  39. {{item.comment_text}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 加载 -->
  45. <view class="loading-more">
  46. <text v-if="tab.list.length"
  47. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  48. <my-nocontent v-else></my-nocontent>
  49. </view>
  50. <!-- 回到顶部 -->
  51. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. tab_list: [{
  60. name: '全部',
  61. type: 'all',
  62. list: [],
  63. loadingClass: true,
  64. loadingText: '正在加载中',
  65. page: 1,
  66. isPage: true
  67. }, {
  68. name: '待付款',
  69. type: 'unpaid',
  70. list: [],
  71. loadingClass: true,
  72. loadingText: '正在加载中',
  73. page: 1,
  74. isPage: true
  75. }, {
  76. name: '待使用',
  77. type: 'paid',
  78. list: [],
  79. loadingClass: true,
  80. loadingText: '正在加载中',
  81. page: 1,
  82. isPage: true
  83. },
  84. {
  85. name: '已完成',
  86. type: 'complete',
  87. list: [],
  88. loadingClass: true,
  89. loadingText: '正在加载中',
  90. page: 1,
  91. isPage: true
  92. },
  93. {
  94. name: '售后',
  95. type: 'after_sales',
  96. list: [],
  97. loadingClass: true,
  98. loadingText: '正在加载中',
  99. page: 1,
  100. isPage: true
  101. }
  102. ],
  103. current: 0, // tab下表
  104. pageSize: 10,
  105. assetsType: '', //账户类型
  106. orderType: []
  107. }
  108. },
  109. onLoad(e) {
  110. this.assetsType = e.type;
  111. },
  112. onShow() {
  113. this.verifyUserInfo();
  114. let tab_item = this.tab_list[this.current];
  115. tab_item.page = 1;
  116. tab_item.isPage = true;
  117. tab_item.loadingClass = true;
  118. tab_item.loadingText = '正在加载中';
  119. this.getUserOrder();
  120. },
  121. methods: {
  122. // 检查当前用户登录状态
  123. verifyUserInfo(){
  124. let userInfo = uni.getStorageSync('userinfo') || {};
  125. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  126. this.$url('/pages/login/index?type=userinfo');
  127. }
  128. },
  129. // 切换tab
  130. change(index) {
  131. this.current = index;
  132. this.getUserOrder();
  133. },
  134. goDetails(tabIndex,index) {
  135. // this.$routerGo('/pages/order/order-details?order_id=55')
  136. console.log(tabIndex,index)
  137. let item = this.tab_list[tabIndex].list[index]
  138. if (item.state == 1) {
  139. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  140. } else if(item.state == 4){
  141. this.$routerGo('/pages/order/apply-details?order_id=' + item.id)
  142. }else {
  143. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  144. }
  145. },
  146. onReachBottom() {
  147. let tab_item = this.tab_list[this.current];
  148. if (tab_item.isPage) {
  149. tab_item.page = tab_item.page + 1;
  150. this.getUserOrder();
  151. }
  152. },
  153. onPullDownRefresh() {
  154. let tab_item = this.tab_list[this.current];
  155. tab_item.page = 1;
  156. tab_item.isPage = true;
  157. tab_item.loadingClass = true;
  158. tab_item.loadingText = '正在加载中';
  159. this.getUserOrder();
  160. uni.stopPullDownRefresh()
  161. },
  162. getUserOrder() {
  163. let per_page = this.pageSize;
  164. let tab_item = this.tab_list[this.current];
  165. this.$http(this.API.API_USERORDER, {
  166. state: this.tab_list[this.current].type,
  167. page: tab_item.page,
  168. per_page
  169. }).then(res => {
  170. if (res.code == 0) {
  171. console.log(res)
  172. if( Object.keys(res.metal_data).length != 0 ) {
  173. this.$routerGo('/pages/login/index?type=userinfo')
  174. }else {
  175. let isPage = res.data.has_more_page;
  176. tab_item.isPage = isPage;
  177. if (isPage) {
  178. tab_item.loadingClass = true;
  179. tab_item.loadingText = '正在加载中';
  180. } else {
  181. tab_item.loadingClass = false;
  182. tab_item.loadingText = '没有更多数据啦~';
  183. }
  184. if (tab_item.page == 1) {
  185. tab_item.list = res.data.items;
  186. } else {
  187. tab_item.list.push(...res.data.items);
  188. }
  189. }
  190. }
  191. }).catch(err => {
  192. });
  193. },
  194. //返回
  195. back() {
  196. if (this.assetsType === 'all2') {
  197. // #ifdef H5
  198. window.history.go(-2)
  199. // #endif
  200. // #ifndef H5
  201. uni.navigateBack({
  202. delta: 2
  203. });
  204. // #endif
  205. } else {
  206. // #ifdef H5
  207. window.history.go(-1)
  208. // #endif
  209. // #ifndef H5
  210. uni.navigateBack({
  211. delta: 1
  212. });
  213. // #endif
  214. }
  215. }
  216. },
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .cu-btn1 {
  221. background-color: white!important;
  222. color: #777!important;
  223. border: 1px solid #777!important;
  224. }
  225. .font-400 {
  226. font-weight: 400;
  227. }
  228. .tag-self {
  229. position: absolute!important;
  230. top: 0!important;
  231. border-radius: 20rpx 0 20rpx 0!important;
  232. width: max-content;
  233. height: 32rpx!important;
  234. }
  235. .title {
  236. font-size: 28rpx;
  237. color: $u-content-color;
  238. height: 98rpx;
  239. }
  240. // tab
  241. .ctab {
  242. width: 100%;
  243. margin: 20rpx 0 0rpx 0rpx;
  244. padding: 0 22rpx;
  245. }
  246. // 商品列表
  247. .com {
  248. width: 100%;
  249. overflow: hidden;
  250. .list {
  251. border-radius: 10rpx;
  252. overflow: hidden;
  253. margin: 30rpx 32rpx;
  254. background-color: #FFFFFF;
  255. // box-shadow: 0 0 10px 5px #e5e5e5;
  256. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  257. align-items: flex-start;
  258. .left {
  259. overflow: hidden;
  260. image {
  261. width: 186rpx;
  262. height: 186rpx;
  263. margin: 20rpx;
  264. border-radius: 10rpx;
  265. }
  266. }
  267. .right {
  268. overflow: hidden;
  269. width: 67%;
  270. .title {
  271. margin: 0rpx 20rpx 0rpx 0;
  272. color: #222222;
  273. font-size: 32rpx;
  274. }
  275. .tips {
  276. margin: 16rpx 0;
  277. overflow: hidden;
  278. .u-line-progress {
  279. width: 112rpx;
  280. overflow: hidden;
  281. margin-right: 20rpx;
  282. }
  283. .progress {
  284. color: #777777;
  285. font-size: 24rpx;
  286. }
  287. .bought {
  288. color: #777777;
  289. font-size: 24rpx;
  290. margin-right: 20rpx;
  291. }
  292. }
  293. .price {
  294. overflow: hidden;
  295. color: #FF0000;
  296. button {
  297. width: 176rpx;
  298. height: 60rpx;
  299. background: #FE9903;
  300. border-radius: 15px;
  301. font-size: 24rpx;
  302. color: #FFFFFF;
  303. margin: 0rpx 20rpx 0rpx 20rpx;
  304. border: none;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>