shop.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view class="content">
  3. <view class="titleNview-placing">
  4. </view>
  5. <!-- 小店头部start -->
  6. <view class="shop-top">
  7. <view class="shop-box">
  8. <view class="left">
  9. <view class="avatar"><image :src="avatar || '/static/error/missing-face.png'" mode=""></image></view>
  10. <view class="avatar-right">
  11. <view class="username">{{store_name}}</view>
  12. <view class="member">{{phone}}</image></view>
  13. </view>
  14. </view>
  15. <view class="right">
  16. <view class="sharing-online-store">分享网店</view>
  17. <view class="img" @click="shareLink"><image src="https://zhibo.liuniu946.com/img/share.png" mode=""></image></view>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 小店头部end -->
  22. <!-- 小店主体start -->
  23. <view class="shop-buttom">
  24. <view class="commodity-box" v-for="item in list" :key="item.id">
  25. <view class="commodity-left"><image :src="item.image" mode=""></image></view>
  26. <view class="commodity-right">
  27. <view class="commodity-right-top">
  28. <view class="top-two">{{item.store_name}}</view>
  29. </view>
  30. <view class="commodity-right-buttom">
  31. <view class="buttom-left">
  32. <view class="price" v-if="userInfo.level > 0">¥{{item.vip_price}}</view>
  33. <view class="price" v-else>¥{{item.price}}</view>
  34. <!-- <view class="original-price">¥{{item.price}}</view> -->
  35. </view>
  36. <view class="buttom-right" @click="navToDetailPage(item)">马上购</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="shareShow" class="Shraremask" @click="cancel">
  42. <view class="mask-content">
  43. <scroll-view class="view-content" scroll-y>
  44. <view class="share-header">分享到</view>
  45. <view class="share-list">
  46. <view class="share-item">
  47. <!-- 微信 -->
  48. <button class="wechat-box" open-type="share">
  49. <image class="itemImage" src="../../static/img/weixin.png" mode=""></image>
  50. <text class="itemText">微信</text>
  51. </button>
  52. <!-- 朋友圈 -->
  53. <!-- <view class="wechat-box" @click="shareToFriend()">
  54. <image class="itemImage" src="https://tmp01.kktv6.com/img/img002.png" mode=""></image>
  55. <text class="itemText">朋友圈</text>
  56. </view> -->
  57. </view>
  58. </view>
  59. </scroll-view>
  60. <view class="bottomButtom b-t" @click="cancel">取消</view>
  61. </view>
  62. </view>
  63. <!-- 小店主体end -->
  64. <u-tabbar v-if="mystore" v-model="current" :list="tabbar" active-color="#FF0000" inactive-color="#f19c99"></u-tabbar>
  65. <u-tabbar v-else v-model="current" :list="tabbar1" active-color="#FF0000" inactive-color="#f19c99"></u-tabbar>
  66. </view>
  67. </template>
  68. <script>
  69. import { mapState, mapMutations } from 'vuex';
  70. import { tabbar } from "@/utils/tabbar.js";
  71. import { tabbar1 } from "@/utils/tabbar.js";
  72. import {getStoreGoods} from '@/api/product.js';
  73. // getStoreGoods
  74. import { userinfo } from '@/api/user.js';
  75. import { getStoreInfo } from '@/api/anchor.js';
  76. // #ifdef H5
  77. import { weixindata } from '@/utils/wxAuthorized';
  78. // #endif
  79. export default{
  80. // #ifdef MP
  81. onShareAppMessage: function(res) {
  82. if (res.from === 'button') {
  83. // 来自页面内分享按钮
  84. let pages = getCurrentPages();
  85. // 获取当前页面
  86. let page = pages[pages.length - 1];
  87. let path = '/' + page.route + '?';
  88. // 保存传值
  89. for (let i in page.options) {
  90. path += i + '=' + page.options[i] + '&';
  91. }
  92. // 保存邀请人
  93. path += 'shopId=' + this.userInfo.store_info.id + '&spread=' + this.userInfo.uid;
  94. let data = {
  95. path: path,
  96. imageUrl: this.userInfo.store_info.image,
  97. title: this.userInfo.store_info.name
  98. };
  99. console.log('data',data)
  100. return data;
  101. }
  102. },
  103. // #endif
  104. data(){
  105. return{
  106. level:'',
  107. spstore_id:false,
  108. store_id: '',
  109. store_switch:'',
  110. mystore:'',
  111. tabbar: tabbar,
  112. tabbar1: tabbar1,
  113. current: 0,
  114. store_name:'',
  115. avatar:'',
  116. phone:'',
  117. list:[],
  118. shareShow: false, //分享
  119. }
  120. },
  121. computed: {
  122. ...mapState(['userInfo']),
  123. },
  124. onLoad(option) {
  125. if(option.shopId){
  126. // 存储商店id
  127. this.store_id = option.shopId;
  128. // 存储传入的商店id
  129. uni.setStorageSync('mystore',this.store_id);
  130. // 存储邀请人
  131. if(option.spread){
  132. uni.setStorageSync('spread', option.spread);
  133. }
  134. }else{
  135. // 当没有传过来商店id时获取缓存商店id
  136. this.store_id = uni.getStorageSync('mystore');
  137. console.log('当没有传过来商店id时获取缓存商店id',this.store_id)
  138. }
  139. this.loadData()
  140. },
  141. // 进入页面刷新数据
  142. onShow() {
  143. this.store_id = uni.getStorageSync('mystore');
  144. console.log('当没有传过来商店id时获取缓存商店id',this.store_id)
  145. this.mystore = uni.getStorageSync('mystore');
  146. this.loadData()
  147. },
  148. methods:{
  149. loadData(){
  150. getStoreInfo({},this.store_id).then(({ data }) =>{
  151. this.store_name = data.name
  152. this.phone = data.phone
  153. this.avatar = data.image
  154. })
  155. getStoreGoods({
  156. page:1,
  157. limit:10,
  158. store_id:this.store_id
  159. }).then(( {data }) =>{
  160. this.list = data
  161. })
  162. // loadIndexs({}).then(({
  163. // data
  164. // }) => {
  165. // this
  166. // console.log('--store_switch---', data.store_switch);
  167. // })
  168. },
  169. shareLink(){
  170. console.log('dainjideniang')
  171. this.shareShow = true;
  172. },
  173. //取消分享
  174. cancel() {
  175. this.shareShow = false;
  176. },
  177. // 具体分享
  178. shareToFriend(item) {
  179. let obj = this;
  180. uni.showLoading({
  181. title: 'Loading...',
  182. mask: true
  183. })
  184. // #ifdef H5
  185. let url = location.href;
  186. // #endif
  187. productCode({
  188. id: obj.goodsid,
  189. type: 1,
  190. // #ifdef MP-WEIXIN
  191. user_type: 'routine', //来源
  192. // #endif
  193. // #ifdef H5
  194. user_type: 'wechat', //来源
  195. // #endif
  196. // #ifdef H5
  197. qurl: url
  198. // #endif
  199. }).then(({ data }) => {
  200. this.backShare = true;
  201. this.shareImage = data.url;
  202. uni.hideLoading();
  203. console.log(data);
  204. }).catch(e=> {
  205. uni.hideLoading()
  206. })
  207. },
  208. // 跳转普通商品
  209. navToDetailPage(item) {
  210. uni.navigateTo({
  211. url: '/pages/product/product?id=' + item.id + '&sid=' + this.store_id
  212. })
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss">
  218. .content {
  219. height: 100%;
  220. // height:var(--status-bar-height);
  221. // padding-top: var(--status-bar-height);
  222. .titleNview-placing{
  223. height:var(--status-bar-height);
  224. background: #ff0000;
  225. width: 100%;
  226. }
  227. .shop-top {
  228. padding-top: 88rpx;
  229. width: 750rpx;
  230. height: 305rpx;
  231. background-color: #FF0000;
  232. border-radius: 0 0 7% 7%;
  233. display: flex;
  234. justify-content: center;
  235. .shop-box {
  236. width: 710rpx;
  237. height: 90rpx;
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. .left {
  242. // width: 230rpx;
  243. height: 90rpx;
  244. display: flex;
  245. flex-direction: row;
  246. .avatar {
  247. image {
  248. width: 90rpx;
  249. height: 90rpx;
  250. border-radius: 50%;
  251. }
  252. }
  253. .avatar-right {
  254. padding-left: 13rpx;
  255. display: flex;
  256. flex-direction: column;
  257. justify-content: space-between;
  258. .username {
  259. // width: 100rpx;
  260. height: 32rpx;
  261. font-size: 30rpx;
  262. // font-weight: bold;
  263. color: #ffffff;
  264. line-height: 24px;
  265. }
  266. .member {
  267. width: 93rpx;
  268. height: 34rpx;
  269. font-size: 30rpx;
  270. color: #FFFFFF;
  271. display: flex;
  272. align-items: center;
  273. image {
  274. width: 93rpx;
  275. height: 34rpx;
  276. }
  277. }
  278. }
  279. }
  280. .right {
  281. display: flex;
  282. flex-direction: row;
  283. .sharing-online-store {
  284. width: 118rpx;
  285. height: 29rpx;
  286. color: #ffffff;
  287. }
  288. .img {
  289. width: 42rpx;
  290. height: 42rpx;
  291. image {
  292. width: 42rpx;
  293. height: 42rpx;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. .shop-buttom {
  300. width: 710rpx;
  301. margin: 0 auto;
  302. background: #ffffff;
  303. border-radius: 10rpx;
  304. margin-top: -70rpx;
  305. .commodity-box {
  306. display: flex;
  307. flex-direction: row;
  308. // padding: 40rpx 20rpx;
  309. padding: 24rpx;
  310. border-bottom: 1px solid #F0F0F0;
  311. .commodity-left {
  312. padding-right: 22rpx;
  313. image {
  314. width: 144rpx;
  315. height: 144rpx;
  316. }
  317. }
  318. .commodity-right {
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-between;
  322. width: 100%;
  323. .commodity-right-top {
  324. display: flex;
  325. flex-direction: column;
  326. justify-content: space-around;
  327. .top-two {
  328. font-size: 32rpx;
  329. font-weight: 500;
  330. color: #666666;
  331. word-break: break-all;
  332. display: -webkit-box;
  333. -webkit-line-clamp: 1;
  334. -webkit-box-orient: vertical;
  335. overflow: hidden;
  336. }
  337. }
  338. .commodity-right-buttom {
  339. display: flex;
  340. justify-content: space-between;
  341. .buttom-left {
  342. display: flex;
  343. justify-content: space-between;
  344. padding-bottom: 15rpx;
  345. .price {
  346. // width: 117rpx;
  347. height: 36rpx;
  348. font-size: 32rpx;
  349. font-weight: bold;
  350. color: #FF0000;
  351. }
  352. .original-price {
  353. height: 18rpx;
  354. font-size: 22rpx;
  355. margin-left: 12rpx;
  356. margin-top: 12rpx;
  357. text-decoration: line-through;
  358. color: #AAAAAA;
  359. }
  360. }
  361. .buttom-right {
  362. // background: linear-gradient(180deg,#FD4646,#FF3535);
  363. background-color: #ff0000;
  364. border-radius: 26px;
  365. padding: 6rpx 18rpx;
  366. font-size: 26rpx;
  367. font-weight: 400;
  368. color: #FFFFFF;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. .Shraremask {
  376. position: fixed;
  377. left: 0;
  378. top: 0;
  379. right: 0;
  380. bottom: 0;
  381. display: flex;
  382. justify-content: center;
  383. align-items: flex-end;
  384. z-index: 998;
  385. transition: 0.3s;
  386. background-color: rgba(51, 51, 51, 0.6);
  387. .bottomButtom {
  388. position: absolute;
  389. left: 0;
  390. bottom: 0;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. width: 100%;
  395. height: 90rpx;
  396. background: #fff;
  397. z-index: 9;
  398. font-size: $font-base + 2rpx;
  399. color: $font-color-dark;
  400. }
  401. }
  402. .mask-content {
  403. margin-bottom: 88rpx;
  404. width: 100%;
  405. height: 380rpx;
  406. transition: 0.3s;
  407. background: #fff;
  408. &.has-bottom {
  409. padding-bottom: 90rpx;
  410. }
  411. .view-content {
  412. height: 100%;
  413. }
  414. }
  415. .share-header {
  416. height: 110rpx;
  417. font-size: $font-base + 2rpx;
  418. color: font-color-dark;
  419. display: flex;
  420. align-items: center;
  421. justify-content: center;
  422. padding-top: 10rpx;
  423. &:before,
  424. &:after {
  425. content: '';
  426. width: 240rpx;
  427. height: 0;
  428. border-top: 1px solid $border-color-base;
  429. transform: scaleY(0.5);
  430. margin-right: 30rpx;
  431. }
  432. &:after {
  433. margin-left: 30rpx;
  434. margin-right: 0;
  435. }
  436. }
  437. .share-list {
  438. display: flex;
  439. width: 80%;
  440. margin: 0rpx auto;
  441. }
  442. .share-item {
  443. min-width: 33.33%;
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. height: 180rpx;
  448. width: 100%;
  449. .wechat-box {
  450. width: 50%;
  451. height: 100%;
  452. background: #ffffff;
  453. border: 0;
  454. display: flex;
  455. align-items: center;
  456. flex-direction: column;
  457. &::after {
  458. border: 0;
  459. }
  460. .itemImage {
  461. width: 80rpx;
  462. height: 80rpx;
  463. margin-bottom: 16rpx;
  464. }
  465. .itemText {
  466. font-size: $font-base;
  467. color: $font-color-base;
  468. line-height: 2;
  469. }
  470. }
  471. }
  472. </style>