index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. uni.navigateTo({
  151. url:`/pages/order/tips?goods=${id}`
  152. })
  153. },
  154. kfPop(){
  155. const data = uni.getStorageSync("contact");
  156. this.$refs.kfService.open(data);
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .content{
  163. position: fixed;
  164. z-index: 1;
  165. top: 0;
  166. left: 0;
  167. bottom: 0;
  168. right: 0;
  169. background-color: #ededed;
  170. display: flex;
  171. flex-direction: column;
  172. }
  173. .home-load{
  174. .store-header{
  175. display: flex;
  176. gap: 20upx;
  177. border-bottom: 2upx solid #f8f8f8;
  178. border-top: 2upx solid #f8f8f8;
  179. align-items: center;
  180. padding: 20upx;
  181. }
  182. }
  183. .home-store{
  184. background-color: $main-color;
  185. padding: 20rpx;
  186. display: flex;
  187. align-items: center;
  188. gap: 20rpx;
  189. image {
  190. width: 92rpx;
  191. height: 92rpx;
  192. border: 2rpx solid #fff;
  193. border-radius: 20rpx;
  194. }
  195. .store-info{
  196. flex: 1;
  197. .name {
  198. color: #fff;
  199. font-weight: bold;
  200. font-size: 32rpx;
  201. }
  202. .desc {
  203. color: $main-sub-color;
  204. font-size: 28rpx;
  205. margin-top: 10rpx;
  206. }
  207. }
  208. .store-kf{
  209. background-color: #fff;
  210. color: $main-color;
  211. font-size: 24rpx;
  212. padding: 20rpx 30rpx;
  213. border-radius: 40rpx;
  214. }
  215. }
  216. .store-address {
  217. display: flex;
  218. align-self: center;
  219. width: calc(100% - 40rpx);
  220. margin: 0 auto;
  221. box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0 0 0 / 0.05);
  222. background-color: #fff;
  223. border-bottom-right-radius:20rpx;
  224. border-bottom-left-radius:20rpx;
  225. padding: 20rpx 20rpx;
  226. gap: 20rpx;
  227. color: #475569;
  228. .address-info {
  229. flex: 1 1 0%;
  230. display: flex;
  231. align-items: center;
  232. gap: 10rpx;
  233. overflow: hidden;
  234. image {
  235. width: 40rpx;
  236. height: 40rpx;
  237. }
  238. .address{
  239. flex: 1;
  240. overflow: hidden;
  241. text-overflow: ellipsis;
  242. white-space: nowrap;
  243. }
  244. }
  245. .store-time{
  246. color: #94a3b8;
  247. }
  248. }
  249. .home-goods{
  250. height: 0;
  251. flex: 1;
  252. width: 95%;
  253. margin: 20rpx auto;
  254. .list-item{
  255. display: flex;
  256. align-items: center;
  257. gap: 20rpx;
  258. background-color: #fff;
  259. padding: 20rpx;
  260. margin-top: 20rpx;
  261. border-radius: 20rpx;
  262. .info{
  263. flex: 1 1 0%;
  264. overflow: hidden;
  265. .title{
  266. overflow: hidden;
  267. text-overflow: ellipsis;
  268. white-space: nowrap;
  269. font-size: 32rpx;
  270. color: #333;
  271. font-weight: 900;
  272. }
  273. .tags {
  274. color: #94a3b8;
  275. font-size: 24rpx;
  276. margin: 10rpx 0;
  277. }
  278. .price-btn{
  279. display: flex;
  280. align-items: center;
  281. gap: 20rpx;
  282. align-items: flex-end;
  283. .price{
  284. font-size: 30rpx;
  285. color: $main-color;
  286. font-weight: 900;
  287. }
  288. .price-line {
  289. color: #999999;font-size: 24rpx;text-decoration-line: line-through;
  290. }
  291. .buy-btn{
  292. margin-left: auto;
  293. margin-right: 0;
  294. background-color: $main-color;
  295. color: #fff;
  296. border-radius: 30rpx;
  297. font-size: 28rpx;
  298. padding: 10rpx 20rpx;
  299. }
  300. }
  301. }
  302. .image {
  303. height: 180rpx;
  304. overflow: hidden;display: flex;align-items: center;min-width: 180rpx;
  305. position: relative;
  306. text {
  307. background-color: $main-color;
  308. color: #fff;
  309. position: absolute;
  310. top: 10rpx;
  311. left: 10rpx;
  312. font-size: 24rpx;
  313. border-radius: 30rpx;
  314. padding: 10rpx 15rpx;
  315. }
  316. image {
  317. width: 180rpx;
  318. border-radius: 10upx;
  319. height: 100%;
  320. }
  321. }
  322. }
  323. .goods-title{
  324. display: flex;
  325. align-items: center;
  326. justify-content: space-between;
  327. .title-left{
  328. .name {
  329. font-size: 34rpx;
  330. color: #333;
  331. font-weight: 900;
  332. }
  333. text {
  334. color: $main-color;
  335. font-weight: 700;
  336. font-size: 24rpx;
  337. }
  338. }
  339. .title-more{
  340. display: flex;
  341. align-items: center;
  342. color: #94a3b8;
  343. font-size: 28rpx;
  344. image {
  345. width: 28rpx;
  346. height: 28rpx;
  347. }
  348. }
  349. }
  350. }
  351. </style>