index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="content">
  3. <template v-if="isLoading">
  4. <view class="store-header">
  5. <view class="home-store">
  6. <view class="store-logo" style="width: 100rpx;"><view class="skeleton-line animate"></view></view>
  7. <view class="store-info">
  8. <view class="name"><view class="skeleton-line animate"></view></view>
  9. <view class="desc"><view class="skeleton-line animate"></view></view>
  10. </view>
  11. <view class="store-kf" style="width: 100rpx;"><view class="skeleton-line animate"></view></view>
  12. </view>
  13. <view class="store-address">
  14. <view class="address-info">
  15. <view class="address"><view class="skeleton-line animate"></view></view>
  16. </view>
  17. <view class="store-time"><view class="skeleton-line animate"></view></view>
  18. </view>
  19. </view>
  20. <scroll-view class="home-goods" scroll-y scroll-with-animation>
  21. <view class="goods-list">
  22. <view class="list-item" v-for="(item,index) in 4" :key="index">
  23. <view class="image">
  24. <view class="skeleton-line animate"></view>
  25. </view>
  26. <view class="info">
  27. <view class="title"><view class="skeleton-line animate"></view></view>
  28. <view class="tags"></view>
  29. <view class="tags"><view class="skeleton-line animate"></view></view>
  30. <view class="price-btn">
  31. <view class="price"><view class="skeleton-line animate"></view></view>
  32. <view class="price-line"><view class="skeleton-line animate"></view></view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </template>
  39. <template v-else>
  40. <view class="store-header">
  41. <view class="home-store">
  42. <view class="store-logo"><image :src="storeData.poi_logo"></image></view>
  43. <view class="store-info">
  44. <view class="name">{{ storeData.poi_name }}</view>
  45. <view class="desc">{{ storeData.poi_city }}</view>
  46. </view>
  47. <view class="store-kf" @click="kfPop">联系客服</view>
  48. </view>
  49. <view class="store-address">
  50. <view class="address-info">
  51. <image src="/static/image/location.svg"></image>
  52. <view class="address">{{ storeData.poi_address }}</view>
  53. </view>
  54. <view class="store-time">营业 {{ storeData.start_at?storeData.start_at:'-' }} - {{ storeData.end_at?storeData.end_at:'-' }}</view>
  55. </view>
  56. </view>
  57. <scroll-view class="home-goods" scroll-y scroll-with-animation>
  58. <view class="goods-title">
  59. <view class="title-left">
  60. <text>HOT DEALS</text>
  61. <view class="name">正在抢购</view>
  62. </view>
  63. <view class="title-more">全部商品 <image src="/static/image/right.svg"></image> </view>
  64. </view>
  65. <view class="goods-list">
  66. <view class="list-item" v-for="(item,index) in goodsData" :key="index" @click="toDetail(item.goods_id)">
  67. <view class="image">
  68. <image :src="item.image_list[0].url"></image>
  69. <text>{{$dialog.disFormat(item.price,item.line_price)}}折</text>
  70. </view>
  71. <view class="info">
  72. <view class="title">{{item.product_name}}</view>
  73. <view class="tags"></view>
  74. <view class="tags">已售{{item.sale_stock}}</view>
  75. <view class="price-btn">
  76. <view class="price">{{$dialog.formatMoney(item.price)}}</view>
  77. <view class="price-line">{{$dialog.formatMoney(item.line_price)}}</view>
  78. <view class="buy-btn">立即抢购</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </scroll-view>
  84. </template>
  85. <halfLogin ref="loginCom" @success="loginSuccess"></halfLogin>
  86. <kfService ref="kfService"></kfService>
  87. </view>
  88. </template>
  89. <script>
  90. var app;
  91. export default {
  92. data() {
  93. return {
  94. optionData: null,
  95. storeId:"",
  96. isLoading:true,
  97. storeData:null,
  98. goodsData:[],
  99. isLogin:null
  100. }
  101. },
  102. onLoad(options) {
  103. app = this;
  104. const tokenPoi = uni.getStorageSync("contact");
  105. if (options.store != null) {
  106. app.storeId = options.store;
  107. } else if (tokenPoi && tokenPoi.poi_id != null) {
  108. app.storeId = tokenPoi.poi_id;
  109. } else {
  110. app.storeId = "7644106137976965139";
  111. }
  112. app.isLogin = uni.getStorageSync("user_token");
  113. app.optionData = options;
  114. app.getData()
  115. },
  116. methods: {
  117. loginSuccess(token){
  118. app.isLogin = token;
  119. },
  120. async getData(){
  121. if (!app.storeId) return ;
  122. app.isLoading = true;
  123. app.optionData.store = app.storeId;
  124. var res = await app.$api.home.data.get(app.optionData);
  125. app.isLoading = false;
  126. if (res.code !== 1) {
  127. return app.$dialog.showSuccess(res.msg)
  128. }
  129. uni.setStorageSync("poiId",res.data.store.poi_id);
  130. app.storeData = res.data.store;
  131. uni.setStorageSync("contact",res.data.store);
  132. app.getGoods();
  133. },
  134. async getGoods(){
  135. app.optionData.store = app.storeId;
  136. var resp = await app.$api.home.goods.get(app.optionData);
  137. if (resp.code !== 200) {
  138. return app.$dialog.showSuccess(resp.msg)
  139. }
  140. app.goodsData = resp.data.rows;
  141. },
  142. toDetail(id){
  143. // if (!app.isLogin) {
  144. // this.$refs.loginCom.open();
  145. // return ;
  146. // }
  147. uni.navigateTo({
  148. url:`/pages/goods/detail?goods=${id}`
  149. })
  150. },
  151. async kfPop(){
  152. if (!app.isLogin) {
  153. this.$refs.loginCom.open();
  154. return ;
  155. }
  156. var resp = await this.$api.goods.check.get();
  157. if (resp.code == 0) {
  158. return app.$dialog.showSuccess(resp.msg);
  159. }
  160. if (resp.data.user == 0) {
  161. this.$refs.loginCom.open(2);
  162. return ;
  163. }
  164. const data = uni.getStorageSync("contact");
  165. this.$refs.kfService.open(data);
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .content{
  172. position: fixed;
  173. z-index: 1;
  174. top: 0;
  175. left: 0;
  176. bottom: 0;
  177. right: 0;
  178. background-color: #ededed;
  179. display: flex;
  180. flex-direction: column;
  181. }
  182. .home-load{
  183. .store-header{
  184. display: flex;
  185. gap: 20upx;
  186. border-bottom: 2upx solid #f8f8f8;
  187. border-top: 2upx solid #f8f8f8;
  188. align-items: center;
  189. padding: 20upx;
  190. }
  191. }
  192. .home-store{
  193. background-color: $main-color;
  194. padding: 20rpx;
  195. display: flex;
  196. align-items: center;
  197. gap: 20rpx;
  198. image {
  199. width: 92rpx;
  200. height: 92rpx;
  201. border: 2rpx solid #fff;
  202. border-radius: 20rpx;
  203. }
  204. .store-info{
  205. flex: 1;
  206. .name {
  207. color: #fff;
  208. font-weight: bold;
  209. font-size: 32rpx;
  210. }
  211. .desc {
  212. color: $main-sub-color;
  213. font-size: 28rpx;
  214. margin-top: 10rpx;
  215. }
  216. }
  217. .store-kf{
  218. background-color: #fff;
  219. color: $main-color;
  220. font-size: 24rpx;
  221. padding: 20rpx 30rpx;
  222. border-radius: 40rpx;
  223. }
  224. }
  225. .store-address {
  226. display: flex;
  227. align-self: center;
  228. width: calc(100% - 40rpx);
  229. margin: 0 auto;
  230. box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0 0 0 / 0.05);
  231. background-color: #fff;
  232. border-bottom-right-radius:20rpx;
  233. border-bottom-left-radius:20rpx;
  234. padding: 20rpx 20rpx;
  235. gap: 20rpx;
  236. color: #475569;
  237. .address-info {
  238. flex: 1 1 0%;
  239. display: flex;
  240. align-items: center;
  241. gap: 10rpx;
  242. overflow: hidden;
  243. image {
  244. width: 40rpx;
  245. height: 40rpx;
  246. }
  247. .address{
  248. flex: 1;
  249. overflow: hidden;
  250. text-overflow: ellipsis;
  251. white-space: nowrap;
  252. }
  253. }
  254. .store-time{
  255. color: #94a3b8;
  256. }
  257. }
  258. .home-goods{
  259. height: 0;
  260. flex: 1;
  261. width: 95%;
  262. margin: 20rpx auto;
  263. .list-item{
  264. display: flex;
  265. align-items: center;
  266. gap: 20rpx;
  267. background-color: #fff;
  268. padding: 20rpx;
  269. margin-top: 20rpx;
  270. border-radius: 20rpx;
  271. .info{
  272. flex: 1 1 0%;
  273. overflow: hidden;
  274. .title{
  275. overflow: hidden;
  276. text-overflow: ellipsis;
  277. white-space: nowrap;
  278. font-size: 32rpx;
  279. color: #333;
  280. font-weight: 900;
  281. }
  282. .tags {
  283. color: #94a3b8;
  284. font-size: 24rpx;
  285. margin: 10rpx 0;
  286. }
  287. .price-btn{
  288. display: flex;
  289. align-items: center;
  290. gap: 20rpx;
  291. align-items: flex-end;
  292. .price{
  293. font-size: 30rpx;
  294. color: $main-color;
  295. font-weight: 900;
  296. }
  297. .price-line {
  298. color: #999999;font-size: 24rpx;text-decoration-line: line-through;
  299. }
  300. .buy-btn{
  301. margin-left: auto;
  302. margin-right: 0;
  303. background-color: $main-color;
  304. color: #fff;
  305. border-radius: 30rpx;
  306. font-size: 28rpx;
  307. padding: 10rpx 20rpx;
  308. }
  309. }
  310. }
  311. .image {
  312. height: 180rpx;
  313. overflow: hidden;display: flex;align-items: center;min-width: 180rpx;
  314. position: relative;
  315. text {
  316. background-color: $main-color;
  317. color: #fff;
  318. position: absolute;
  319. top: 10rpx;
  320. left: 10rpx;
  321. font-size: 24rpx;
  322. border-radius: 30rpx;
  323. padding: 10rpx 15rpx;
  324. }
  325. image {
  326. width: 180rpx;
  327. border-radius: 10upx;
  328. height: 100%;
  329. }
  330. }
  331. }
  332. .goods-title{
  333. display: flex;
  334. align-items: center;
  335. justify-content: space-between;
  336. .title-left{
  337. .name {
  338. font-size: 34rpx;
  339. color: #333;
  340. font-weight: 900;
  341. }
  342. text {
  343. color: $main-color;
  344. font-weight: 700;
  345. font-size: 24rpx;
  346. }
  347. }
  348. .title-more{
  349. display: flex;
  350. align-items: center;
  351. color: #94a3b8;
  352. font-size: 28rpx;
  353. image {
  354. width: 28rpx;
  355. height: 28rpx;
  356. }
  357. }
  358. }
  359. }
  360. </style>