金诚优选前端代码
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.

445 lines
14 KiB

  1. <template>
  2. <view id="order-index">
  3. <view class="navbar mx-1px-bottom">
  4. <block v-for="(item, index) in tabList" :key="index" >
  5. <view :id="index" class="navbar-item" :class="activeIndex == index ? 'activity' : ''" @tap="tabClick">
  6. <view class="navbar-title">{{item.title}}</view>
  7. </view>
  8. </block>
  9. <view class="navbar-slider" :style="'width: ' + width + 'px; transform: translateX(' + sliderOffset + 'px); -webkit-transform: translateX(' + sliderOffset + 'px);'"></view>
  10. </view>
  11. <view class="tab-panel">
  12. <view class="tab-content" :hidden="activeIndex != 0">
  13. <view class="order-box">
  14. <view class="order-item__none" v-if="dataList[0] == '' && tabList[activeIndex].init">
  15. 暂无数据
  16. </view>
  17. <view v-for="(item, idx) in dataList[0]" :key="idx">
  18. <view class="order-item" :data-no="order.order_no" v-for="(order, index) in dataList[0][idx]" :key="index" @tap="jumps">
  19. <view class="item-top">
  20. <view class="indent mx-1px-bottom">
  21. <view class="order-num">
  22. <span>线上门店</span> | 订单编号{{order.order_no}}
  23. </view>
  24. <view class="order-type">
  25. {{typeList[0]}}
  26. </view>
  27. </view>
  28. </view>
  29. <view class="item-middle">
  30. <view class="middle-item mx-1px-bottom" v-for="(good, index) in order.items" :key="index" >
  31. <image :src="good.item_meta.image"></image>
  32. <view class="commodity_detail">
  33. <view class="detail_name">
  34. {{good.item_name}}
  35. </view>
  36. <view class="detail_num">
  37. <view class="num_css">
  38. <span>{{good.quantity}}</span>
  39. <span>{{good.item_meta.specs_text}}</span>
  40. </view>
  41. <view class="num_money">
  42. {{good.total_yuan}}
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="item-bottom" >
  49. <view class="all-money">
  50. {{order.count}}, 共计 {{order.total_yuan}}
  51. </view>
  52. <view class="button-box">
  53. 立即评价
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="loadingbox" :hidden="!tabList[0].show">
  59. {{showText}}
  60. </view>
  61. </view>
  62. </view>
  63. <view class="tab-content" :hidden="activeIndex != 1">
  64. <view class="order-box">
  65. <view class="order-item__none" v-if="dataList[1] == '' && tabList[activeIndex].init">
  66. 暂无数据
  67. </view>
  68. <view v-for="(item, indexs) in dataList[1]" :key="indexs" >
  69. <view class="evaluate-item" v-for="(comment, index) in dataList[1][indexs]" :key="index">
  70. <view class="adapter mx-1px-bottom">
  71. <view class="adapter_item">
  72. <view class="item_title">
  73. <view class="adapter-img">
  74. <image :src="comment.user.avatar"></image>
  75. <!-- <view class="justify globalColor">V{{comment.user.grade}}</view> -->
  76. </view>
  77. <view class="text">{{comment.user.nick_name}}</view>
  78. </view>
  79. <view class="rater">
  80. <uni-rate size="18" disabled="true" active-color="red" :value="comment.point" ></uni-rate>
  81. </view>
  82. </view>
  83. <view class="adapter_type">
  84. <span>{{comment.created_at}}</span>
  85. <span>颜色分类{{comment.item_meta.specs_text}}</span>
  86. </view>
  87. <view class="adapter_content">
  88. <view class="content_item">
  89. <view class="content_text">
  90. {{comment.contents}}
  91. </view>
  92. <view class="content_img">
  93. <view class="img_item" v-for="(imgList, index) in comment.pic_list" :key="index" >
  94. <view class="img">
  95. <image mode="widthFix" :src="imgList"></image>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="commodity" :hidden="order_item == ''">
  103. <view class="commodity_item" :data-id="comment.item_meta.detail_id" @tap="jumpDetail">
  104. <view class="commodity_img">
  105. <image :src="comment.item_meta.image"></image>
  106. </view>
  107. <view class="commodity_detail">
  108. <view class="detail_name">
  109. {{comment.order_item.item_name}}
  110. </view>
  111. <view class="detail_num">
  112. <view class="num_css">
  113. <span>{{comment.order_item.quantity}}</span>
  114. <span>{{comment.item_meta.specs_text}}</span>
  115. </view>
  116. <view class="num_money">
  117. {{comment.order_item.total_yuan}}
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <view class="loadingbox" :hidden="!tabList[0].show">
  126. {{showText}}
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  135. import uniRate from "@/components/score/uni-rate/uni-rate.vue"
  136. export default {
  137. data() {
  138. return {
  139. status: {
  140. 0: 0,
  141. 1: 0,
  142. 2: 0,
  143. 3: 0
  144. },
  145. activeIndex: 0,
  146. sliderOffset: 0,
  147. sliderLeft: 0,
  148. width: 0,
  149. tabList: [{
  150. title: "待评价",
  151. init: false,
  152. line: false,
  153. statusNum: {
  154. page: 0,
  155. more: true
  156. },
  157. show: false
  158. }, {
  159. title: "已评价",
  160. init: false,
  161. line: false,
  162. statusNum: {
  163. page: 0,
  164. more: true
  165. },
  166. show: false
  167. }],
  168. dataList: {
  169. 0: [],
  170. 1: []
  171. },
  172. orderList: {},
  173. typeList: {
  174. 0: '已完成'
  175. },
  176. showText: '正在加载下一页数据'
  177. };
  178. },
  179. components:{
  180. uniRate
  181. },
  182. onReachBottom(e) {
  183. var status = this.activeIndex;
  184. var page = this.tabList[status].page + 1;
  185. var tabList = `tabList[${status}]`;
  186. if (this.tabList[status].more) {
  187. if (status == 0) {
  188. // this.setData({
  189. // [`${tabList}.show`]: true
  190. // });
  191. this.tabList.show=true;
  192. this.orderListF(page);
  193. } else if (status == 1) {
  194. // this.setData({
  195. // [`${tabList}.show`]: true
  196. // });
  197. this.tabList.show=true;
  198. this.commentList(page);
  199. }
  200. } else {
  201. wx.showToast({
  202. title: '再拉也没有啦'
  203. });
  204. }
  205. },
  206. onShow() {
  207. wx.showLoading({
  208. title: "加载中",
  209. mask: true
  210. });
  211. wx.getSystemInfo({
  212. success: res => {
  213. this.setData({
  214. width: res.windowWidth / this.tabList.length,
  215. sliderOffset: res.windowWidth / this.tabList.length * this.activeIndex
  216. });
  217. }
  218. });
  219. this.orderListF();
  220. },
  221. onLoad(e) {},
  222. components: {},
  223. props: {},
  224. methods: {
  225. tabClick(e) {
  226. var status = e.currentTarget.id;
  227. // this.setData({
  228. // sliderOffset: e.currentTarget.offsetLeft,
  229. // activeIndex: status
  230. // });
  231. //
  232. this.sliderOffset=e.currentTarget.offsetLeft;
  233. this.activeIndex=status
  234. if (status == 0) {
  235. if (!this.tabList[status].init) {
  236. wx.showLoading({
  237. title: "加载中",
  238. mask: true
  239. });
  240. this.orderListF();
  241. }
  242. } else if (status == 1) {
  243. if (!this.tabList[status].init) {
  244. wx.showLoading({
  245. title: "加载中",
  246. mask: true
  247. });
  248. this.commentList();
  249. }
  250. }
  251. },
  252. jump(e) {
  253. wx.navigateTo({
  254. url: '/pages/order/detail/detail?no=' + e.currentTarget.dataset.no
  255. });
  256. },
  257. jumps(e) {
  258. wx.navigateTo({
  259. url: '/pages/order/evaluate/evaluate?no=' + e.currentTarget.dataset.no
  260. });
  261. console.log(1);
  262. },
  263. jumpDetail(e) {
  264. wx.navigateTo({
  265. url: '/pages/store/detail/detail?id=' + e.currentTarget.dataset.id
  266. });
  267. },
  268. //获取已评价列表
  269. commentList(page = 1) {
  270. this.$http.get({
  271. api: 'api/comment/list',
  272. header: {
  273. Authorization: this.$cookieStorage.get('user_token')
  274. },
  275. data: {
  276. page: page
  277. }
  278. }).then(res => {
  279. if (res.statusCode == 200) {
  280. res = res.data;
  281. if (res.status) {
  282. console.log(res.data);
  283. var pages = res.meta.pagination;
  284. var current_page = pages.current_page;
  285. var total_pages = pages.total_pages;
  286. var tabList = `tabList[1]`;
  287. // this.setData({
  288. // [`dataList[1][${page - 1}]`]: res.data,
  289. // [`${tabList}.init`]: true,
  290. // [`${tabList}.page`]: current_page,
  291. // [`${tabList}.more`]: current_page < total_pages
  292. // });
  293. this.dataList[1][page - 1]=res.data;
  294. this.tabList[1].init=res.data;
  295. this.tabList[1].page=current_page;
  296. this.tabList[1].more=current_page < total_pages;
  297. res.data.forEach(v => {
  298. /* Rater.init(`${v.id}`, {
  299. value: v.point,
  300. disabled: true,
  301. activeColor: '#EA4448',
  302. fontSize: 14
  303. })*/
  304. });
  305. } else {
  306. wx.showToast({
  307. title: "请求失败",
  308. image: '../../../static/error.png'
  309. });
  310. }
  311. } else {
  312. wx.showModal({
  313. content: '请求失败',
  314. showCancel: false
  315. });
  316. }
  317. wx.hideLoading();
  318. }).catch(rej => {
  319. wx.showToast({
  320. title: "请求失败",
  321. image: '../../../static/error.png'
  322. });
  323. wx.hideLoading();
  324. });
  325. },
  326. // 获取订单列表
  327. orderListF(page = 1, type = 0) {
  328. var token = this.$cookieStorage.get('user_token');
  329. var params = {};
  330. params.status = 4, params.page = page;
  331. params.type = type;
  332. params.channel = '';
  333. this.$http.get({
  334. api: 'api/order/list',
  335. header: {
  336. Authorization: token
  337. },
  338. data: params
  339. }).then(res => {
  340. if (res.statusCode == 200) {
  341. res = res.data;
  342. if (res.status) {
  343. console.log(res.data);
  344. var pages = res.meta.pagination;
  345. var current_page = pages.current_page;
  346. var total_pages = pages.total_pages;
  347. var tabList = `tabList[0]`;
  348. // this.setData({
  349. // [`dataList[0][${page - 1}]`]: res.data,
  350. // [`${tabList}.init`]: true,
  351. // [`${tabList}.page`]: current_page,
  352. // [`${tabList}.more`]: current_page < total_pages
  353. // });
  354. this.dataList[0][page - 1]=res.data;
  355. this.tabList[0].init=res.data;
  356. this.tabList[0].page=current_page;
  357. this.tabList[0].more=current_page < total_pages;
  358. } else {
  359. wx.showToast({
  360. title: res.message,
  361. image: '../../../static/error.png'
  362. });
  363. }
  364. } else {
  365. wx.showModal({
  366. content: '请求失败',
  367. showCancel: false
  368. });
  369. }
  370. wx.hideLoading();
  371. }).catch(rej => {
  372. wx.showToast({
  373. title: "请求失败",
  374. image: '../../../static/error.png'
  375. });
  376. wx.hideLoading();
  377. });
  378. },
  379. setData: function (obj) {
  380. let that = this;
  381. let keys = [];
  382. let val, data;
  383. Object.keys(obj).forEach(function (key) {
  384. keys = key.split('.');
  385. val = obj[key];
  386. data = that.$data;
  387. keys.forEach(function (key2, index) {
  388. if (index + 1 == keys.length) {
  389. that.$set(data, key2, val);
  390. } else {
  391. if (!data[key2]) {
  392. that.$set(data, key2, {});
  393. }
  394. }
  395. data = data[key2];
  396. });
  397. });
  398. }
  399. },
  400. computed: {},
  401. watch: {}
  402. };
  403. </script>
  404. <style rel="stylesheet/less" lang="less">
  405. @import "comment";
  406. </style>