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

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