index.vue 8.8 KB

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