rights.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <app-layout>
  3. <view class="title main-center cross-center">
  4. <image :src="svipImg.left" ></image>
  5. <view class="title-text">会员卡权益</view>
  6. <image :src="svipImg.right" ></image>
  7. </view>
  8. <view v-if="is_free_delivery == 1" class="is-free cross-center">
  9. <image src="./../image/free.png"></image>
  10. <view>自营商品包邮</view>
  11. </view>
  12. <view class="is-free cross-center">
  13. <image src="./../image/object.png"></image>
  14. <view>折扣对象</view>
  15. </view>
  16. <view class="obj">
  17. <view class="all" v-if="card.image_type_info_detail.all">
  18. <view class="all-item main-center">
  19. <view>全部自营商品</view>
  20. </view>
  21. </view>
  22. <view v-if="card.image_type_info_detail.cats.length > 0">
  23. <view class="obj-title cross-center main-center">
  24. <view class="line"></view>
  25. <view>指定分类</view>
  26. <view class="line"></view>
  27. </view>
  28. <view class="cat-list dir-left-wrap">
  29. <view class="cat-item t-omit" :key="item.value" @click="toCat(item.value)" v-for="item in card.image_type_info_detail.cats">{{item.label}}</view>
  30. </view>
  31. </view>
  32. <view v-if="card.image_type_info_detail.goods.length > 0">
  33. <view class="obj-title cross-center main-center">
  34. <view class="line"></view>
  35. <view>{{card.image_type_info_detail.all ? '为您推荐(特殊商品除外)' : '指定商品'}}</view>
  36. <view class="line"></view>
  37. </view>
  38. <view class="goods-holder"></view>
  39. </view>
  40. </view>
  41. <u-ordinary-list :showBuyBtn="0" :list="card.image_type_info_detail.goods" :theme="getTheme" :list-style="3"></u-ordinary-list>
  42. </app-layout>
  43. </template>
  44. <script>
  45. import uOrdinaryList from '../../../components/page-component/u-goods-list/u-ordinary-list.vue';
  46. import { mapGetters, mapState } from "vuex";
  47. export default {
  48. data() {
  49. return {
  50. card: {
  51. image_type_info_detail: {
  52. goods: [],
  53. cats: [],
  54. all: false
  55. }
  56. },
  57. is_free_delivery: 0,
  58. page: 1,
  59. more: false,
  60. id: 0
  61. }
  62. },
  63. components: {
  64. uOrdinaryList
  65. },
  66. computed: {
  67. ...mapState({
  68. svipImg: state => state.mallConfig.__wxapp_img.vip_card
  69. }),
  70. ...mapGetters('mallConfig', {
  71. getTheme: 'getTheme',
  72. })
  73. },
  74. methods: {
  75. toCat(id) {
  76. uni.navigateTo({
  77. url: '/pages/goods/list?cat_id=' + id
  78. });
  79. },
  80. getCard(id) {
  81. let that = this;
  82. that.$showLoading({
  83. type: 'global',
  84. text: '加载中...'
  85. });
  86. that.$request({
  87. url: that.$api.vip_card.index_right
  88. }).then(response=>{
  89. if(response.code === 0) {
  90. that.id = id;
  91. that.card = response.data.right;
  92. that.is_free_delivery = response.data.right.is_free_delivery;
  93. if(that.card.image_type_info_detail.all) {
  94. that.getRecommend();
  95. }else {
  96. that.$hideLoading();
  97. }
  98. }else {
  99. that.$hideLoading();
  100. uni.showToast({
  101. title: response.msg,
  102. icon: 'none',
  103. duration: 1000
  104. });
  105. }
  106. }).catch(() => {
  107. that.$hideLoading();
  108. });
  109. },
  110. getList() {
  111. let that = this;
  112. that.$showLoading({
  113. type: 'global',
  114. text: '加载中...'
  115. });
  116. that.$request({
  117. url: that.$api.vip_card.index,
  118. }).then(response=>{
  119. if(response.code === 0) {
  120. that.card.image_type_info_detail.cats = response.data.user.image_type_info_detail.cats;
  121. that.card.image_type_info_detail.goods = response.data.user.image_type_info_detail.goods;
  122. that.card.image_type_info_detail.all = response.data.user.image_type_info_detail.all;
  123. that.is_free_delivery = response.data.user.image_is_free_delivery;
  124. if(that.card.image_type_info_detail.all) {
  125. that.getRecommend();
  126. }else {
  127. that.getGoods();
  128. }
  129. }else {
  130. that.$hideLoading();
  131. if(response.msg === '超级会员卡已关闭' || response.msg === '无超级会员卡权限') {
  132. uni.redirectTo({
  133. url: '/pages/index/index'
  134. })
  135. }
  136. uni.showToast({
  137. title: response.msg,
  138. icon: 'none',
  139. duration: 1000
  140. });
  141. }
  142. }).catch(() => {
  143. that.$hideLoading();
  144. });
  145. },
  146. getRecommend() {
  147. let that = this;
  148. that.$request({
  149. url: that.$api.vip_card.recommend,
  150. }).then(response => {
  151. that.$hideLoading();
  152. if(response.code === 0) {
  153. that.card.image_type_info_detail.goods = response.data.list;
  154. }else {
  155. if(response.msg === '超级会员卡已关闭' || response.msg === '无超级会员卡权限') {
  156. uni.redirectTo({
  157. url: '/pages/index/index'
  158. })
  159. }
  160. uni.showToast({
  161. title: response.msg,
  162. icon: 'none',
  163. duration: 1000
  164. });
  165. }
  166. }).catch(() => {
  167. that.$hideLoading();
  168. });
  169. },
  170. getGoods() {
  171. let that = this;
  172. that.more = false;
  173. that.$request({
  174. url: that.$api.vip_card.right,
  175. data: {
  176. page: that.page
  177. }
  178. }).then(response=>{
  179. that.$hideLoading();
  180. that.first = false;
  181. if(response.code === 0) {
  182. that.card.image_type_info_detail.goods = response.data.list;
  183. that.page++;
  184. if(response.data.list.length == response.data.pagination.pageSize) {
  185. that.more = true;
  186. }
  187. }else {
  188. if(response.msg === '超级会员卡已关闭' || response.msg === '无超级会员卡权限') {
  189. uni.redirectTo({
  190. url: '/pages/index/index'
  191. })
  192. }
  193. uni.showToast({
  194. title: response.msg,
  195. icon: 'none',
  196. duration: 1000
  197. });
  198. }
  199. }).catch(() => {
  200. that.$hideLoading();
  201. });
  202. }
  203. },
  204. onReachBottom() {
  205. if(this.id == 0 && this.more) {
  206. this.getGoods();
  207. }
  208. },
  209. onLoad(options) { this.$commonLoad.onload(options);
  210. if(options.id > 0) {
  211. this.getCard(options.id);
  212. }else {
  213. this.getList();
  214. }
  215. }
  216. }
  217. </script>
  218. <style scoped lang="scss">
  219. .title {
  220. height: #{118rpx};
  221. width: 100%;
  222. background-color: #fff;
  223. .title-text {
  224. margin: 0 #{20rpx};
  225. font-size: #{32rpx};
  226. color: #342e25;
  227. }
  228. image {
  229. width: #{60rpx};
  230. height: #{19rpx};
  231. }
  232. }
  233. .is-free {
  234. height: #{118rpx};
  235. padding: 0 #{40rpx};
  236. font-size: #{32rpx};
  237. margin-top: #{20rpx};
  238. color: #342e25;
  239. background-color: #fff;
  240. image {
  241. height: #{40rpx};
  242. width: #{40rpx};
  243. margin-right: #{22rpx};
  244. }
  245. }
  246. .obj {
  247. background-color: #fff;
  248. .all {
  249. padding-bottom: #{15rpx};
  250. .all-item {
  251. height: #{90rpx};
  252. }
  253. }
  254. .obj-title {
  255. color: #a6a6a6;
  256. font-size: #{23rpx};
  257. .line {
  258. width: #{40rpx};
  259. height: #{2rpx};
  260. background-color: #bbbbbb;
  261. margin: 0 #{17rpx};
  262. }
  263. }
  264. .goods-holder {
  265. height: #{32rpx};
  266. }
  267. .cat-list {
  268. padding: 0 #{12rpx} #{54rpx};
  269. .cat-item {
  270. width: #{218rpx};
  271. margin: #{56rpx} #{12rpx} #{6rpx};
  272. text-align: center;
  273. font-size: #{28rpx};
  274. color: #353535;
  275. }
  276. }
  277. }
  278. </style>