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

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