shop.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view :style="vuex_skin" style="width: 100vw;overflow: hidden;">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <u-navbar title-color="#fff" z-index="90" :border-bottom="false" :is-back="false" title="积分换礼"
  5. :background="{'backgroundColor': vuex_theme.shopBg}"></u-navbar>
  6. <!-- #endif -->
  7. <mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback" :safearea="true">
  8. <view class="bg-card">
  9. <view class="info" style="display: flex;justify-content: space-between;">
  10. <view class="flex" v-if="vuex_userId">
  11. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" :src="avatar">
  12. </image>
  13. <view class="center data">
  14. <text style="color: #FFD7D9;">我的积分:</text>
  15. <text class="text-bold text-xxl">{{userData.userPufaPoint || 0}}</text>
  16. </view>
  17. </view>
  18. <view class="flex" v-else @click="showLogin">
  19. <image style="width: 90rpx;height: 90rpx;border-radius: 50%;" src="/static/icon/unlogin.png">
  20. </image>
  21. <view class="center data">
  22. <text style="color: #FFFFFF;font-weight: 800;">点击授权登录</text>
  23. </view>
  24. </view>
  25. <view class="center" style="margin-right: -30rpx;">
  26. <view class="cu-btn round sm rule"
  27. @click="$jump('/pages/introduce/notice?title=积分规则')">
  28. 积分兑换规则
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="swiper">
  34. <u-swiper :list="swiperList" name="url" mode="rect" border-radius="12" height="270" @click="handleSwiper"></u-swiper>
  35. </view>
  36. <filter-bar :currentIndex="currentIndex" ref="filterBar" @exchangeTag="handeExchangeTag"></filter-bar>
  37. <view class="recommend-info">
  38. <view class="goods-list">
  39. <navigator hover-class="none" :url="'detail?id='+item.id" class="list" v-for="(item,index) in list"
  40. :key="index">
  41. <view class="pictrue">
  42. <image :src="item.imgUrl"></image>
  43. </view>
  44. <view class="title-tag" style="text-align: center;font-weight: 800;">
  45. <text class="text-cut-1">{{item.name}}</text>
  46. </view>
  47. <view class="price-info">
  48. <view class="user-price">
  49. <text class="max">{{item.point}}积分</text>
  50. </view>
  51. </view>
  52. <view class="bottom padding-top-20">
  53. <button class="cu-btn round text-white bg-base"
  54. style="width: 140upx;height: 50upx;">兑换</button>
  55. </view>
  56. </navigator>
  57. </view>
  58. </view>
  59. </mescroll-body>
  60. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  61. <u-tabbar :bg-color="tabbar.bgColor" :icon-size="tabbar.iconSize" :height="100" :border-top="tabbar.borderTop"
  62. :inactive-color="tabbar.inactiveColor" :active-color="tabbar.activeColor" :list="tabbar.list">
  63. </u-tabbar>
  64. </view>
  65. </template>
  66. <script>
  67. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  68. import filterBar from "@/components/filterBar/filterBar.vue"
  69. import {tabbar} from "@/assets/http/tabbar.js"
  70. export default {
  71. components: {
  72. filterBar,
  73. },
  74. mixins: [MescrollMixin],
  75. data() {
  76. return {
  77. //tabbar
  78. tabbar: {},
  79. swiperList: [],
  80. downOption: {
  81. auto: false
  82. },
  83. upOption:{
  84. auto:false
  85. },
  86. avatar: '',
  87. userData: {},
  88. list: [],
  89. isWorksSkip: false, //是否从作品详情页跳转进来
  90. currentIndex: 0, //筛选栏下标,默认为0, 1: 销量 2
  91. searchType: 0, //搜索类型
  92. }
  93. },
  94. onShow() {
  95. this.init()
  96. },
  97. async onLoad() {
  98. //加载底部导航栏
  99. this.fetchTabbar()
  100. //获取轮播图
  101. this.fetchSwiperList()
  102. //加载积分商城
  103. this.fetchGoods()
  104. },
  105. watch: {
  106. isWorksSkip(newVal, oldVal) {
  107. if(newVal != oldVal){this.fetchGoods();}
  108. },
  109. searchType(newVal, oldVal) {
  110. if(newVal != oldVal){this.fetchGoods();}
  111. }
  112. },
  113. methods: {
  114. handleSwiper(index){
  115. let url = this.swiperList[index].path;
  116. if(!!url && (url.indexOf('http://') > -1 || url.indexOf('https://') > -1) ){
  117. window.location.href = url;
  118. }
  119. },
  120. fetchGoods(){
  121. // #ifdef MP-WEIXIN
  122. this.mescroll.resetUpScroll();
  123. // #endif
  124. // #ifdef H5
  125. setTimeout(()=>{
  126. this.mescroll.resetUpScroll();
  127. },50)
  128. // #endif
  129. },
  130. async fetchTabbar() {
  131. this.tabbar = tabbar
  132. if (this.vuex_theme.bgColor) {
  133. this.tabbar.activeColor = this.vuex_theme.bgColor
  134. }else{
  135. this.tabbar.activeColor = this.$config.themeRed.theme.bgColor
  136. }
  137. },
  138. async fetchSwiperList() {
  139. try {
  140. let {
  141. POINT_GOODS_SETTING
  142. } = (await this.$api.platform.getPlatformParams({
  143. keys: 'POINT_GOODS_SETTING'
  144. })).data.data;
  145. this.swiperList = JSON.parse(POINT_GOODS_SETTING).indexImageList
  146. } catch (e) {
  147. console.log(e);
  148. }
  149. },
  150. init() {
  151. this.avatar = this.$cache.get('userInfo').avatar
  152. this.fetchUserInfo()
  153. this.isWorksSkip = uni.getStorageSync('isWorksSkip');
  154. },
  155. fetchUserInfo() {
  156. if (!this.vuex_phone) {
  157. return
  158. }
  159. let params = {
  160. phone: this.vuex_phone
  161. }
  162. this.$api.loginUser.userHeatValueAndPufaPoint(params).then(res => {
  163. this.userData = res.data.data
  164. })
  165. },
  166. downCallback() {
  167. setTimeout(() => {
  168. this.fetchSwiperList()
  169. this.mescroll.resetUpScroll();
  170. }, 800)
  171. },
  172. upCallback(mescroll) {
  173. try {
  174. let params = {};
  175. if(this.isWorksSkip){
  176. params = {
  177. searchType: this.searchType,
  178. current: mescroll.num,
  179. size: mescroll.size,
  180. activeId: this.vuex_active_setting.defaultActiveId
  181. }
  182. }else{
  183. params = {
  184. searchType: this.searchType,
  185. current: mescroll.num,
  186. size: mescroll.size,
  187. }
  188. }
  189. this.$api.pointgoods.queryList(params).then(res => {
  190. let data = res.data.data.records
  191. let total = res.data.data.total
  192. mescroll.endBySize(data.length, total);
  193. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  194. this.list = this.list.concat(data); //追加新数据
  195. })
  196. } catch (e) {
  197. console.error(e);
  198. this.mescroll.endErr()
  199. }
  200. },
  201. handeExchangeTag(index) {
  202. this.currentIndex = index;
  203. this.mescroll.scrollTo(0, 300); //滚动列表到指定位置(y,t),y=0回到列表顶部,t时长,单位ms,默认300
  204. if(this.currentIndex == 0){
  205. this.searchType = 0
  206. }else if(this.currentIndex == 1){
  207. this.searchType = 1
  208. }else if(this.currentIndex == 2){
  209. if(this.$refs.filterBar.sort != 'asc'){
  210. this.searchType = 3
  211. }else{
  212. this.searchType = 2
  213. }
  214. }
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .rule {
  221. background-color: rgba(0,0,0,0.26);
  222. color: #FFFFFF;
  223. padding: 20rpx 40rpx 20rpx 30rpx;
  224. }
  225. .bg-card {
  226. // position: relative;
  227. width: 100vw;
  228. height: 260rpx;
  229. background-color: var(--bgColor);
  230. border-radius: 0 0 10% 10%;
  231. .info {
  232. display: flex;
  233. padding: 30rpx 0rpx 0rpx 40rpx;
  234. .data {
  235. color: #FFFFFF;
  236. margin-left: 10rpx;
  237. }
  238. }
  239. }
  240. .swiper {
  241. margin-top: -120rpx;
  242. padding: 0 20rpx;
  243. }
  244. /* 为你推荐 */
  245. .recommend-info {
  246. width: 100%;
  247. border-radius: 20rpx;
  248. .recommend-title {
  249. display: flex;
  250. align-items: center;
  251. justify-content: center;
  252. width: 100%;
  253. height: 100rpx;
  254. .title {
  255. display: flex;
  256. align-items: center;
  257. image {
  258. width: 416rpx;
  259. height: 40rpx;
  260. }
  261. }
  262. }
  263. .goods-list {
  264. display: flex;
  265. flex-wrap: wrap;
  266. justify-content: space-between;
  267. padding: 0 20rpx;
  268. .list {
  269. width: 49%;
  270. height: 550rpx;
  271. margin-bottom: 20rpx;
  272. background-color: #FFFFFF;
  273. border-radius: 12rpx;
  274. overflow: hidden;
  275. .pictrue {
  276. display: flex;
  277. justify-content: center;
  278. width: 100%;
  279. image {
  280. width: 100%;
  281. height: 340rpx;
  282. }
  283. }
  284. .title-tag {
  285. // display: flex;
  286. height: 70rpx;
  287. padding: 20rpx;
  288. }
  289. .price-info {
  290. display: flex;
  291. flex-wrap: wrap;
  292. align-items: center;
  293. justify-content: center;
  294. padding: 0 20rpx;
  295. height: 50rpx;
  296. .user-price {
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. text {
  301. color: #e72226;
  302. }
  303. .min {
  304. font-size: 24rpx;
  305. }
  306. .max {
  307. font-size: 32rpx;
  308. }
  309. }
  310. .vip-price {
  311. padding-left: 20rpx;
  312. display: flex;
  313. align-items: center;
  314. image {
  315. width: 26rpx;
  316. height: 26rpx;
  317. margin-right: 10rpx;
  318. }
  319. text {
  320. text-decoration: line-through;
  321. color: #8c8c8c;
  322. font-size: 24rpx;
  323. }
  324. }
  325. }
  326. .bottom {
  327. margin: 10rpx 0;
  328. display: flex;
  329. justify-content: center;
  330. align-items: flex-end;
  331. }
  332. }
  333. }
  334. }
  335. </style>