时空网前端
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.

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