index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <!-- <view class="content">-->
  3. <!-- <image class="logo" src="/static/logo.png"></image>-->
  4. <!-- <view class="text-area">-->
  5. <!-- <text class="title">{{title}}</text>-->
  6. <!-- </view>-->
  7. <!-- <button @click="test">测试按钮</button>-->
  8. <!-- <van-button type="primary">van的button</van-button>-->
  9. <!-- </view>-->
  10. <view class="content">
  11. <van-search
  12. :value="value"
  13. placeholder="请输入搜索关键词"
  14. @search="onSearch"
  15. @cancel="onCancel"
  16. @change="onChange"
  17. @click="gotoSearch"
  18. />
  19. <!-- show-action -->
  20. <!-- <scroll-view scroll-x="true">
  21. <view>1</view>
  22. </scroll-view> -->
  23. <!-- <view class="uni-margin-wrap">
  24. <swiper :autoplay="true">
  25. <swiper-item item-id="A">
  26. <view class="swiper-item uni-bg-red"><text class="swiper-item-Text">A</text></view>
  27. </swiper-item>
  28. <swiper-item item-id="B">
  29. <view class="swiper-item uni-bg-green"><text class="swiper-item-Text">B</text></view>
  30. </swiper-item>
  31. <swiper-item item-id="C">
  32. <view class="swiper-item uni-bg-blue"><text class="swiper-item-Text">C</text></view>
  33. </swiper-item>
  34. </swiper>
  35. </view> -->
  36. <!-- 轮播图区域 -->
  37. <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true" class="swiper">
  38. <swiper-item v-for="(item, i) in swiperList" :key="i" class="swiper-item">
  39. <navigator class="swiper-image" :url="'/subpkg/goods_detail/goods_detail?goods_id=' + item.goods_id">
  40. <img :src="item.image_src" alt="">
  41. </navigator>
  42. <view class="shop-info-container">
  43. <text class="shop-name" @click="navigateToDetail(item)" style="font-size: 28rpx; color: #fff;">{{ item.shop_name }}</text>
  44. </view>
  45. </swiper-item>
  46. </swiper>
  47. <!-- <image class="logo" src="/static/logo.png"></image>
  48. <view class="text-area">
  49. <text class="title">{{title}}</text>
  50. </view> -->
  51. <!-- 123 -->
  52. <!-- <my-grid :shops="getShowShops()"></my-grid>-->
  53. <!-- <shop-card></shop-card>-->
  54. <view v-if="flag===0">
  55. <view v-for="(item,i) in getShowShops()" :key="i">
  56. <shop-card :shop-id="item.id" :shop-name="item.storeName" :shop-icon="item.storePicUrl" @click="nevigateToDetail(item.id)" :shop-info="200" :shopdistance="800" :tag="tags[i]" :coupon="[{desc:'满20减2',full:20,count:2},{desc:'满50减8',full:50,count:8}]" :mark="4.5"></shop-card>
  57. </view>
  58. </view>
  59. <view v-else>
  60. <shop-card :shop-id="getShowShops()[flag-1].id" :shop-name="getShowShops()[flag-1].storeName" :shop-icon="getShowShops()[flag-1].storePicUrl" @click="nevigateToDetail(getShowShops()[flag-1].id)" :shop-info="200" :shopdistance="0.8" :tag="tags[i]" :coupon="[{desc:'满20减2',full:20,count:2},{desc:'满50减8',full:50,count:8}]" :mark="4.5"></shop-card>
  61. </view>
  62. </view>
  63. </template>
  64. <script >
  65. import {mapState,mapMutations,mapGetters} from'vuex'
  66. console.log(uni.$http)
  67. export default {
  68. data() {
  69. return {
  70. tags:[['应季水果综合榜TOP1'],['无公害绿色蔬菜'],['0添加糖分色素']],
  71. coupon:[
  72. [{desc:'满20减2',full:20,count:2},{desc:'满50减8',full:50,count:8}],
  73. [{desc:'满20减2',full:20,count:2},{desc:'满50减8',full:50,count:8}],
  74. [{desc:'满20减2',full:20,count:2},{desc:'满50减8',full:50,count:8}]],
  75. title: 'Hello',
  76. value:"",
  77. flag:0,
  78. //这是轮播图的数据列表
  79. swiperList:[{goods_id: 123,
  80. image_src: "../../static/lunbo/1.jpg",
  81. shop_name: "清甜多汁的鲜果,来源自淮铺肥沃的土地!我们严格把关每一个果品的品质,为您带来全季新鲜的水果体验。",id:1},{goods_id: 124,
  82. image_src: "../../static/lunbo/2.jpg",
  83. shop_name: "淮铺这片富饶之地孕育了各种营养蔬菜,丰富的维生素和矿物质滋养着您的健康。品尝大自然的馈赠,尽在淮铺蔬菜。",id:2},{goods_id: 125,
  84. image_src: "../../static/lunbo/3.jpg",
  85. shop_name: "酸甜可口的天然果汁,新鲜压榨而来!没有任何添加剂,只有纯正的水果滋味。让您随时随地补充果汁元气!",id:3}],
  86. }
  87. },
  88. onLoad() {
  89. // this.getShowShops()
  90. },
  91. methods: {
  92. ...mapGetters('m_shop',['getShowShops']),
  93. nevigateToDetail(item){
  94. uni.navigateTo({
  95. url: `/subpkg/shopdetail/shopdetail?shopID=${JSON.stringify(item.id)}`
  96. })
  97. },
  98. test() {
  99. console.log(1, "test");
  100. },
  101. onSearch() {
  102. if (this.value==="水果") {
  103. this.flag=1
  104. }
  105. else if (this.value==="蔬菜") {
  106. this.flag=2
  107. }
  108. else {
  109. this.flag=0
  110. }
  111. uni.reLaunch({
  112. url: '/pages//pages/index/index'
  113. });
  114. console.log(this.flag)
  115. console.log(this.value)
  116. console.log('查询了');
  117. },
  118. onCancel(){
  119. console.log('取消了');
  120. },
  121. gotoSearch(){
  122. console.log('去了');
  123. uni.navigateTo({
  124. url:"/subpkg/search/search"
  125. })
  126. },
  127. onChange(target){
  128. console.log('修改了',target);
  129. this.value=target.detail
  130. },
  131. navigateToDetail(item) {
  132. console.log(item)
  133. uni.navigateTo({
  134. url: `/subpkg/shopdetail/shopdetail?shopID=${JSON.stringify(item.id)}`
  135. })
  136. }
  137. },
  138. }
  139. </script>
  140. <style lang="scss">
  141. //swiper{
  142. // height: 330rpx;
  143. // width: 95%;
  144. // .swiper-item,
  145. // image{
  146. // width: 100%;
  147. // height: 100%;
  148. // }
  149. //}
  150. //.content {
  151. // display: flex;
  152. // flex-direction: column;
  153. // align-items: center;
  154. // justify-content: center;
  155. //}
  156. .logo {
  157. height: 200rpx;
  158. width: 200rpx;
  159. margin-top: 200rpx;
  160. margin-left: auto;
  161. margin-right: auto;
  162. margin-bottom: 50rpx;
  163. }
  164. .text-area {
  165. display: flex;
  166. justify-content: center;
  167. }
  168. .title {
  169. font-size: 36rpx;
  170. color: #8f8f94;
  171. }
  172. .swiper {
  173. position: relative;
  174. }
  175. //
  176. .swiper-item {
  177. position: relative;
  178. }
  179. .swiper-image {
  180. display: block;
  181. }
  182. .shop-info-container {
  183. position: absolute;
  184. height: 40px;
  185. bottom: 0;
  186. left: 0;
  187. right: 0;
  188. background-color: rgba(0, 0, 0, 0.5);
  189. padding: 10rpx;
  190. text-align: center;
  191. }
  192. //
  193. //.shop-name {
  194. // font-size: 28rpx;
  195. // color: #fff;
  196. //}
  197. </style>