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

336 lines
8.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 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: 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. <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 24rpx 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. showLogin: true
  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. if(this.showLogin){
  127. this.showLogin = false;
  128. this.$url('/pages/login/index?type=userinfo');
  129. }else{
  130. this.showLogin = true;
  131. this.$url('/pages/index/index', {type: 'switch'});
  132. }
  133. }
  134. },
  135. // 切换tab
  136. change(index) {
  137. this.current = index;
  138. this.getUserOrder();
  139. },
  140. goDetails(tabIndex,index) {
  141. // this.$routerGo('/pages/order/order-details?order_id=55')
  142. console.log(tabIndex,index)
  143. let item = this.tab_list[tabIndex].list[index]
  144. if (item.state == 1) {
  145. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  146. } else if(item.state == 4){
  147. this.$routerGo('/pages/order/apply-details?order_id=' + item.id)
  148. }else {
  149. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  150. }
  151. },
  152. onReachBottom() {
  153. let tab_item = this.tab_list[this.current];
  154. if (tab_item.isPage) {
  155. tab_item.page = tab_item.page + 1;
  156. this.getUserOrder();
  157. }
  158. },
  159. onPullDownRefresh() {
  160. let tab_item = this.tab_list[this.current];
  161. tab_item.page = 1;
  162. tab_item.isPage = true;
  163. tab_item.loadingClass = true;
  164. tab_item.loadingText = '正在加载中';
  165. this.getUserOrder();
  166. uni.stopPullDownRefresh()
  167. },
  168. getUserOrder() {
  169. let per_page = this.pageSize;
  170. let tab_item = this.tab_list[this.current];
  171. this.$http(this.API.API_USERORDER, {
  172. state: this.tab_list[this.current].type,
  173. page: tab_item.page,
  174. per_page
  175. }).then(res => {
  176. if (res.code == 0) {
  177. console.log(res)
  178. if( Object.keys(res.metal_data).length != 0 ) {
  179. this.$routerGo('/pages/login/index?type=userinfo')
  180. }else {
  181. let isPage = res.data.has_more_page;
  182. tab_item.isPage = isPage;
  183. if (isPage) {
  184. tab_item.loadingClass = true;
  185. tab_item.loadingText = '正在加载中';
  186. } else {
  187. tab_item.loadingClass = false;
  188. tab_item.loadingText = '没有更多数据啦~';
  189. }
  190. if (tab_item.page == 1) {
  191. tab_item.list = res.data.items;
  192. } else {
  193. tab_item.list.push(...res.data.items);
  194. }
  195. }
  196. }
  197. }).catch(err => {
  198. });
  199. },
  200. //返回
  201. back() {
  202. if (this.assetsType === 'all2') {
  203. // #ifdef H5
  204. window.history.go(-2)
  205. // #endif
  206. // #ifndef H5
  207. uni.navigateBack({
  208. delta: 2
  209. });
  210. // #endif
  211. } else {
  212. // #ifdef H5
  213. window.history.go(-1)
  214. // #endif
  215. // #ifndef H5
  216. uni.navigateBack({
  217. delta: 1
  218. });
  219. // #endif
  220. }
  221. }
  222. },
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .cu-btn1 {
  227. background-color: white!important;
  228. color: #777!important;
  229. border: 1px solid #777!important;
  230. }
  231. .font-400 {
  232. font-weight: 400;
  233. }
  234. .tag-self {
  235. position: absolute!important;
  236. top: 0!important;
  237. border-radius: 20rpx 0 20rpx 0!important;
  238. width: max-content;
  239. height: 32rpx!important;
  240. }
  241. .title {
  242. font-size: 28rpx;
  243. color: $u-content-color;
  244. height: 98rpx;
  245. }
  246. // tab
  247. .ctab {
  248. width: 100%;
  249. margin: 20rpx 0 0rpx 0rpx;
  250. padding: 0 22rpx;
  251. }
  252. // 商品列表
  253. .com {
  254. width: 100%;
  255. overflow: hidden;
  256. .list {
  257. border-radius: 10rpx;
  258. overflow: hidden;
  259. margin: 30rpx 32rpx;
  260. background-color: #FFFFFF;
  261. // box-shadow: 0 0 10px 5px #e5e5e5;
  262. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  263. align-items: flex-start;
  264. .left {
  265. overflow: hidden;
  266. image {
  267. width: 186rpx;
  268. height: 186rpx;
  269. margin: 20rpx;
  270. border-radius: 10rpx;
  271. }
  272. }
  273. .right {
  274. overflow: hidden;
  275. width: 67%;
  276. .title {
  277. margin: 0rpx 20rpx 0rpx 0;
  278. color: #222222;
  279. font-size: 32rpx;
  280. }
  281. .tips {
  282. margin: 16rpx 0;
  283. overflow: hidden;
  284. .u-line-progress {
  285. width: 112rpx;
  286. overflow: hidden;
  287. margin-right: 20rpx;
  288. }
  289. .progress {
  290. color: #777777;
  291. font-size: 24rpx;
  292. }
  293. .bought {
  294. color: #777777;
  295. font-size: 24rpx;
  296. margin-right: 20rpx;
  297. }
  298. }
  299. .price {
  300. overflow: hidden;
  301. color: #FF0000;
  302. button {
  303. width: 176rpx;
  304. height: 60rpx;
  305. background: #FE9903;
  306. border-radius: 15px;
  307. font-size: 24rpx;
  308. color: #FFFFFF;
  309. margin: 0rpx 20rpx 0rpx 20rpx;
  310. border: none;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. </style>