index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="content">
  3. <view class="varHeight"></view>
  4. <view class="banner position-relative">
  5. <image class="bgImg" src="../../static/img/img10.png" mode="scaleToFill"></image>
  6. <view class="flex shpingInfo position-relative">
  7. <view class="logoBox flex">
  8. <image class="logo" :src="info.logo" mode="scaleToFill"></image>
  9. <view class="shopingTitle">{{info.title}}</view>
  10. </view>
  11. <icon class="shopingExit" type="clear" color="#FFFFFF" @click="backUrl"></icon>
  12. </view>
  13. <view class="serachBox flex position-relative">
  14. <view class="serachInput flex">
  15. <icon :size="iconSize" type="search" color="#FFFFFF"></icon>
  16. <input class="search" placeholder="搜索" @blur='confirm' placeholder-style="color:#ffffff" type="text" :value="search" @confirm="confirm" />
  17. </view>
  18. </view>
  19. </view>
  20. <view class="list position-relative">
  21. <list ref='dataList'></list>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import list from '@/pages/product/list';
  27. import {getShoping} from '@/api/shoping.js';
  28. export default {
  29. components: { list },
  30. data() {
  31. return {
  32. // 当前选中的滑块
  33. current: 0,
  34. // 门店信息
  35. info: {
  36. logo:'',
  37. title:'',
  38. },
  39. ratio: '', //页面比例信息
  40. search: '' ,//店铺搜索商品
  41. //商店详情
  42. };
  43. },
  44. onLoad(pt) {
  45. // 保存商户id
  46. this.info.id = pt.merid;
  47. this.getShoping();
  48. },
  49. onReachBottom(e) {
  50. // 底部加载数据
  51. this.$refs.dataList.loadData();
  52. },
  53. onReady() {
  54. // 保存商家id
  55. this.$refs.dataList.mer_id = this.info.id;
  56. // 加载数据
  57. this.$refs.dataList.loadData();
  58. // 加载分类
  59. this.$refs.dataList.loadCateList();
  60. let obj = this;
  61. let query = uni.createSelectorQuery();
  62. // 获取页面比例
  63. query
  64. .select('.content')
  65. .fields(
  66. {
  67. size: true
  68. },
  69. e => {
  70. // 保存比例
  71. this.ratio = e.width / 750;
  72. }
  73. )
  74. .exec();
  75. },
  76. computed: {
  77. // 计算图标大小
  78. iconSize() {
  79. return 28 * this.ratio;
  80. }
  81. },
  82. methods: {
  83. //获取商店信息
  84. getShoping(){
  85. let obj = this;
  86. getShoping({
  87. mer_id:this.info.id
  88. }).then(function({ data }) {
  89. obj.info = data
  90. }).catch((e) => {
  91. console.log(e)
  92. });
  93. },
  94. // 滑块切换时触发方法
  95. changeIndex(e) {
  96. this.current = e.current;
  97. },
  98. // 搜索确认事件
  99. confirm(e){
  100. this.$refs.dataList.keyword=e.detail.value;
  101. this.$refs.dataList.page=1
  102. this.$refs.dataList.loadData('refresh');
  103. },
  104. // 回退功能
  105. backUrl(){
  106. uni.navigateBack()
  107. }
  108. }
  109. };
  110. </script>
  111. <style lang="scss">
  112. page,
  113. .content {
  114. height: 100%;
  115. }
  116. .varHeight {
  117. height: var(--status-bar-height);
  118. }
  119. .banner {
  120. .shpingInfo {
  121. padding: 30rpx $page-row-spacing;
  122. .logoBox {
  123. .logo {
  124. height: 90rpx;
  125. width: 90rpx;
  126. border-radius: 10rpx;
  127. }
  128. .shopingTitle {
  129. padding-left: 20rpx;
  130. color: #ffffff;
  131. font-size: $font-lg;
  132. }
  133. }
  134. .shopingExit {
  135. }
  136. }
  137. .serachBox,
  138. .shpingInfo {
  139. z-index: 999;
  140. }
  141. .bgImg {
  142. position: absolute;
  143. top: 0;
  144. left: 0;
  145. width: 100%;
  146. height: 100%;
  147. }
  148. .serachBox {
  149. padding: 0 $page-row-spacing;
  150. padding-bottom: 20rpx;
  151. width: 100%;
  152. .serachInput {
  153. background-color: rgba($color: #f1f1f1, $alpha: 0.5);
  154. border-radius: 100rpx;
  155. padding: 10rpx 25rpx;
  156. width: 100%;
  157. .search {
  158. padding-left: 20rpx;
  159. width: 100%;
  160. color: #ffffff;
  161. font-size: 28rpx;
  162. }
  163. }
  164. }
  165. }
  166. </style>