attentionStore.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <view class="container">
  3. <view v-if="isShow == true">
  4. <view class="special_care_wrap" v-if="!is_show_empty && storeList.length>0">
  5. <view class="shop_content" v-for="(item,index) in storeList" :key="index">
  6. <view class="shop_tips" v-if="(storeData.topNumber > 0 && index == 0) || (storeData.topNumber == 0 && index == 0) || (storeData.topNumber > 0 && index == storeData.topNumber)">
  7. <!-- 特别关注 -->
  8. <image :src="imgUrl+'shop/special_focus.png'" mode="" class="attention_icon" v-if="storeData.topNumber > 0 && index == 0"></image>
  9. <!-- 普通关注 -->
  10. <image :src="imgUrl+'shop/common_concern.png'" mode="" class="attention_icon" v-if="(storeData.topNumber == 0 && index == 0) || (storeData.topNumber > 0 && index == storeData.topNumber)"></image>
  11. </view>
  12. <view class="shop_item special_care" @touchstart="touchStart" @touchmove="touchMove($event,item.storeId)" :style="{left:is_show_btn && item.storeId == storeId?'-160rpx':'0'}"
  13. :class="{shop_item_nogoods:item.goodsList.length == 0}"
  14. >
  15. <view class="shop_detail_wrap" @click="toShopDetail(item.storeId)">
  16. <image :src="item.storeLogo" mode="aspectFit" class="shop_img"></image>
  17. <view class="shop_info">
  18. <view class="shop_name">{{item.storeName}}</view>
  19. <view class="attention_num">
  20. <image :src="imgUrl+'shop/self_support.png'" mode="" class="self_support_icon" v-if="item.isOwnStore == 1"></image>
  21. <text class="attention_text">{{$L('关注')}}{{item.followNumber}}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="shop_img_wrap">
  26. <view class="shop_goods_box" v-for="(goodsItem,goodsIndex) in item.goodsList" :key="goodsIndex" v-if="goodsIndex < 3" @click="toGoodsDetail(goodsItem.defaultProductId,goodsItem.goodsId)">
  27. <image :src="goodsItem.mainImage" mode="heightFix" class="shop_goods_pic"></image>
  28. <view class="shop_goods_price">
  29. <text class="small_price">¥</text><text class="big_price">{{$getPartNumber(goodsItem.goodsPrice,'int')}}</text><text class="small_price">{{$getPartNumber(goodsItem.goodsPrice,'decimal')}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="operate_btn_wrap" v-if="item.storeId == storeId && is_show_btn"
  34. :class="{operate_btn_wrap_nogoods:item.goodsList == 0}"
  35. >
  36. <view class="special_focus_btn operate_btn" @click="setSpecialFocus(item.followId,item.isTop)" v-if="item.isTop == 0" :style="{height:item.goodsList.length == 0?'81rpx':'162rpx'}">
  37. <view class="">{{$L('设为')}}</view>
  38. <view class="">{{$L('特别关注')}}</view>
  39. </view>
  40. <view class="cancel_focus_btn operate_btn cancel_special_focus_btn" @click="cancelFocus(item.followId,item.isTop,'special')" v-if="item.isTop == 1" :style="{height:item.goodsList.length == 0?'81rpx':'162rpx',background:'#FF9518'}">
  41. <view class="">{{$L('取消')}}</view>
  42. <view class="">{{$L('特别关注')}}</view>
  43. </view>
  44. <view class="cancel_focus_btn operate_btn" @click="cancelFocus(item.storeId,item.isTop)" :style="{height:item.goodsList.length == 0?'81rpx':'162rpx'}">取消关注</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 无关注店铺列表空页面 -->
  50. <view class="empty_page" v-if="is_show_empty && storeList.length == 0">
  51. <image :src="imgUrl+'index/empty.png'" mode="" class="empty_img"></image>
  52. <view class="empty_text">{{$L('暂无关注')}}</view>
  53. </view>
  54. <recommendGoods ref='recomment_goods' v-if="is_show_empty"/>
  55. <loadingState :state='loadingState' v-if="recommendLen == 0"/>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import loadingState from "@/components/loading-state.vue";
  61. import recommendGoods from "@/components/recommend-goods.vue"
  62. export default{
  63. data(){
  64. return{
  65. is_show_btn:false, //是否展示右侧操作按钮
  66. startX:'',
  67. startY:'',
  68. is_show_empty:false, //是否展示空页面
  69. storeId:'',
  70. imgUrl:getApp().globalData.imgUrl,
  71. isShow:true,
  72. loadingState: 'first_loading',
  73. pageSize: 10,
  74. current: 1,
  75. loading: false,//是否加载数据
  76. hasMore: true,//是否还有数据
  77. storeList:[], //关注店铺列表
  78. storeData:{}, //店铺数据
  79. recommendLen:0, //推荐商品总数
  80. }
  81. },
  82. components:{
  83. loadingState,
  84. recommendGoods,
  85. },
  86. onLoad(){
  87. this.getStoreList();
  88. // 父页面接收子组件recommend——goods.vue传过来的值
  89. uni.$on("recommendGoods",(options)=>{
  90. this.recommendLen = JSON.parse(options.recommendLen)
  91. })
  92. },
  93. onShow(){
  94. this.recommendLen=0;
  95. this.getStoreList();
  96. },
  97. onPageScroll(e){
  98. this.storeId = ''
  99. },
  100. onReachBottom(){
  101. if(this.is_show_empty){
  102. this.$refs.recomment_goods.getMoreData();
  103. }else{
  104. if(this.hasMore){
  105. this.getStoreList();
  106. }
  107. }
  108. },
  109. methods:{
  110. getStoreList(){
  111. let param = {}
  112. param.url = 'v3/member/front/followStore/list?pageSize='+this.pageSize+'&current='+this.current
  113. param.method = 'GET'
  114. this.loadingState = this.loadingState == 'first_loading'?this.loadingState:'loading';
  115. this.$request(param).then(res=>{
  116. if(res.state == 200){
  117. if(this.current == 1){
  118. this.storeData = res.data;
  119. this.storeList = res.data.storeList;
  120. }else{
  121. this.storeData = res.data;
  122. this.storeList = this.storeList.concat(res.data.storeList);
  123. }
  124. this.hasMore = this.$checkPaginationHasMore(res.data.pagination)
  125. if(this.hasMore){
  126. this.current++;
  127. this.loadingState = 'allow_loading_more'
  128. }else{
  129. this.loadingState = 'no_more_data';
  130. }
  131. if(this.storeList.length == 0){
  132. this.is_show_empty = true;
  133. }else{
  134. this.is_show_empty = false;
  135. }
  136. }
  137. this.loading = false
  138. })
  139. },
  140. touchStart(e){
  141. this.startX = e.touches[0].clientX;
  142. this.startY = e.touches[0].clientY;
  143. },
  144. touchMove(e,storeId){
  145. this.storeId = storeId
  146. // 获得当前坐标
  147. this.currentX = e.touches[0].clientX;
  148. this.currentY = e.touches[0].clientY;
  149. const x = this.startX - this.currentX; //横向移动距离
  150. const y = Math.abs(this.startY - this.currentY); //纵向移动距离,若向左移动有点倾斜也可以接受
  151. if (x > 5) {
  152. //向左滑显示
  153. this.is_show_btn = true
  154. } else if (x < 5) {
  155. //向右滑隐藏
  156. this.is_show_btn = false
  157. }
  158. if(y>50 || y<-50){
  159. this.is_show_btn = false
  160. }
  161. },
  162. // 设为特别关注
  163. setSpecialFocus(followId,isTop){
  164. let param = {}
  165. param.url = 'v3/member/front/followStore/editSpecial'
  166. param.method = 'POST'
  167. param.data = {
  168. followId:followId,
  169. isTop:1
  170. }
  171. this.$request(param).then(res=>{
  172. if(res.state == 200){
  173. uni.showToast({
  174. title:'特别关注成功!',
  175. })
  176. setTimeout(()=>{
  177. this.getStoreList()
  178. this.storeId = ''
  179. this.isShow = false
  180. this.isShow = true
  181. },1500)
  182. }
  183. })
  184. },
  185. // 取消关注
  186. cancelFocus(followId,isTop,type){
  187. let param = {}
  188. param.data = {}
  189. if(type != 'special'){ //普通取消关注
  190. param.url = 'v3/member/front/followStore/edit'
  191. param.data.isCollect = false
  192. param.data.storeIds = followId
  193. }else{ //取消特别关注
  194. param.url = 'v3/member/front/followStore/editSpecial'
  195. param.data.followId = followId
  196. param.data.isTop = 0
  197. }
  198. param.method = 'POST'
  199. this.$request(param).then(res=>{
  200. if(res.state == 200){
  201. uni.showToast({
  202. title:'取消关注成功!'
  203. })
  204. setTimeout(()=>{
  205. this.getStoreList()
  206. this.storeId = ''
  207. this.isShow = false
  208. this.isShow = true
  209. },1500)
  210. }
  211. })
  212. },
  213. // 去店铺详情
  214. toShopDetail(storeId){
  215. uni.navigateTo({
  216. url:'/pages/store/shopHomePage?vid='+storeId
  217. })
  218. },
  219. toGoodsDetail(productId,goodsId){
  220. uni.navigateTo({
  221. url:'/pages/product/detail?productId='+productId+'&goodsId='+goodsId
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss">
  228. page{
  229. background-color: #F5F5F5;
  230. }
  231. ::-webkit-scrollbar{
  232. display: none;
  233. }
  234. .container{
  235. width:750rpx;
  236. box-sizing: border-box;
  237. overflow: hidden;
  238. margin: 0 auto;
  239. .special_care_wrap,.common_care_wrap{
  240. width: 100%;
  241. border-radius: 15rpx;
  242. padding: 0 20rpx;
  243. overflow: hidden;
  244. .shop_content{
  245. background: #FFFFFF;
  246. .shop_tips{
  247. padding-top: 30rpx;
  248. margin-top: 20rpx;
  249. .attention_icon{
  250. width:137rpx;
  251. height:40rpx;
  252. }
  253. }
  254. }
  255. .shop_item{
  256. position: relative;
  257. border-bottom: 1rpx solid #F2F2F2;
  258. transition: all 0.3s;
  259. background: #FFFFFF;
  260. padding-top: 30rpx;
  261. &.shop_item_nogoods{
  262. height: 202rpx;
  263. }
  264. .shop_detail_wrap{
  265. display: flex;
  266. width:100%;
  267. height:80rpx;
  268. padding:0 20rpx;
  269. box-sizing: border-box;
  270. position:relative;
  271. margin-bottom:30rpx;
  272. .shop_img{
  273. width:80rpx;
  274. height: 80rpx;
  275. margin-right:20rpx;
  276. border-radius: 50%;
  277. background-color: #f8f8f8;
  278. }
  279. .shop_info{
  280. display: flex;
  281. flex-direction: column;
  282. justify-content: space-between;
  283. .shop_name{
  284. width:330rpx;
  285. font-size:30rpx;
  286. color:#2d2d2d;
  287. font-weight: bold;
  288. white-space: nowrap;
  289. text-overflow: ellipsis;
  290. overflow: hidden;
  291. }
  292. .attention_num{
  293. display: flex;
  294. align-items: center;
  295. .self_support_icon{
  296. width:50rpx;
  297. height:24rpx;
  298. margin-right:10rpx;
  299. }
  300. .attention_text{
  301. font-size:24rpx;
  302. color:#999;
  303. }
  304. }
  305. }
  306. .shop_more_icon{
  307. width:6rpx;
  308. height:30rpx;
  309. position: absolute;
  310. right:20rpx;
  311. top:0;
  312. }
  313. }
  314. .shop_img_wrap{
  315. padding:0 20rpx 20rpx 20rpx;
  316. display: flex;
  317. .shop_goods_box{
  318. width: 216rpx;
  319. height: 216rpx;
  320. border-radius: 10rpx;
  321. position:relative;
  322. margin-right:10rpx;
  323. .shop_goods_pic{
  324. width: 216rpx;
  325. height: 216rpx;
  326. background-color: #f8f8f8;
  327. border-radius: 10rpx;
  328. }
  329. .shop_goods_price{
  330. width: 216rpx;
  331. height:36rpx;
  332. color:#fff;
  333. text-align: center;
  334. line-height: 36rpx;
  335. position:absolute;
  336. bottom:0;
  337. left:0;
  338. background-color: rgba(0,0,0,0.3);
  339. border-radius: 0 0 10rpx 10rpx;
  340. display: inline-block;
  341. .small_price{
  342. font-size:20rpx;
  343. }
  344. .big_price{
  345. font-size: 24rpx;
  346. }
  347. }
  348. }
  349. }
  350. .shop_img_wrap>view:last-child{
  351. margin-right: 0;
  352. }
  353. .operate_btn_wrap{
  354. position:absolute;
  355. top: 0;
  356. width:160rpx;
  357. height: 374rpx;
  358. right: -160rpx;
  359. display: flex;
  360. flex-direction: column;
  361. justify-content: center;
  362. border-bottom: 1rpx solid #F2F2F2;
  363. background: #FFFFFF;
  364. &.operate_btn_wrap_nogoods{
  365. height: 202rpx;
  366. }
  367. .operate_btn{
  368. width:160rpx;
  369. height:162rpx;
  370. font-size:28rpx;
  371. color:#fff;
  372. display: flex;
  373. justify-content: center;
  374. align-items: center;
  375. padding:0 24rpx;
  376. box-sizing: border-box;
  377. transition: all 0.3s;
  378. }
  379. .special_focus_btn{
  380. background-color: #FF9518 !important;
  381. flex-direction: column !important;
  382. }
  383. .cancel_focus_btn{
  384. background-color: #FF0D24;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .empty_page{
  391. width:750rpx;
  392. height:543rpx;
  393. display: flex;
  394. flex-direction: column;
  395. justify-content: center;
  396. align-items: center;
  397. margin-top:120rpx;
  398. .empty_img{
  399. width:210rpx;
  400. height:210rpx;
  401. margin-bottom:24rpx;
  402. }
  403. .empty_text{
  404. font-size:26rpx;
  405. color:#666;
  406. }
  407. }
  408. .cancel_special_focus_btn{
  409. flex-direction: column;
  410. }
  411. .common_care_wrap{
  412. margin-top:20rpx;
  413. }
  414. </style>