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

129 lines
3.2 KiB

  1. <template>
  2. <view id="coupon-goods">
  3. <view class="commodity-bottom">
  4. <view class="commodity-out" v-for="(item, index) in storeList" :key="index" :data-id="item.goods_id" @tap="jump">
  5. <view class="commodity-box">
  6. <view class="commodity-img">
  7. <image mode="widthFix" :src="item.img"></image>
  8. </view>
  9. <view class="commodity-name">
  10. {{item.name}}
  11. </view>
  12. <view class="commodity-money">
  13. <view class="money">
  14. {{item.sell_price}}
  15. </view>
  16. <view class="discount-tags">
  17. <span class="tags-item" v-for="(tags, index) in item.discount_tags" :key="index" >{{tags}}</span>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {pageLogin, getUrl,config} from '@/common/js/utils.js';
  27. export default {
  28. data() {
  29. return {
  30. storeList: []
  31. };
  32. },
  33. onLoad(e) {
  34. this.queryGoodsList(e.id);
  35. },
  36. components: {},
  37. props: {},
  38. methods: {
  39. // 请求商品列表
  40. queryGoodsList(id) {
  41. var token = this.$cookieStorage.get('user_token') || '';
  42. wx.showLoading({
  43. title: "加载中",
  44. mask: true
  45. });
  46. this.$http.get({
  47. api: 'api/store/list/' + id + '/coupon',
  48. header: {
  49. Authorization: token
  50. }
  51. }).then(res => {
  52. if (res.statusCode == 200) {
  53. res = res.data;
  54. if (res.status && res.data.length) {
  55. this.setData({
  56. storeList: res.data
  57. });
  58. } else {
  59. wx.redirectTo({
  60. url: '/pages/store/list/list'
  61. });
  62. /*wx.showModal({
  63. content: res.message || '请求失败',
  64. showCancel: false
  65. })*/
  66. }
  67. } else {
  68. wx.redirectTo({
  69. url: '/pages/store/list/list'
  70. });
  71. /*wx.showModal({
  72. content: res.message || '请求失败',
  73. showCancel: false
  74. })*/
  75. }
  76. wx.hideLoading();
  77. }).catch(rej => {
  78. wx.hideLoading();
  79. wx.redirectTo({
  80. url: '/pages/store/list/list'
  81. });
  82. /*wx.showModal({
  83. content: res.message || '请求失败',
  84. showCancel: false
  85. })*/
  86. });
  87. },
  88. jump(e) {
  89. var id = e.currentTarget.dataset.id;
  90. wx.navigateTo({
  91. url: '/pages/store/detail/detail?id=' + id
  92. });
  93. },
  94. setData: function (obj) {
  95. let that = this;
  96. let keys = [];
  97. let val, data;
  98. Object.keys(obj).forEach(function (key) {
  99. keys = key.split('.');
  100. val = obj[key];
  101. data = that.$data;
  102. keys.forEach(function (key2, index) {
  103. if (index + 1 == keys.length) {
  104. that.$set(data, key2, val);
  105. } else {
  106. if (!data[key2]) {
  107. that.$set(data, key2, {});
  108. }
  109. }
  110. data = data[key2];
  111. });
  112. });
  113. }
  114. },
  115. computed: {},
  116. watch: {}
  117. };
  118. </script>
  119. <style rel="stylesheet/less" lang="less">
  120. @import "goods";
  121. </style>