index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.image" mode="scaleToFill"></image>
  9. <view class="shopingTitle">{{ info.name }}</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"
  17. :value="search" @confirm="confirm" />
  18. </view>
  19. </view>
  20. </view>
  21. <view class="list position-relative">
  22. <list ref="dataList"></list>
  23. </view>
  24. <view class="cart" @click="navtab">
  25. <view class="text" v-if="total>0">
  26. {{total}}
  27. </view>
  28. <image class="cart-icon" src="/static/img/cartIcon.png" mode="scaleToFill"></image>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import list from '@/pages/product/list';
  34. import {
  35. getShoping
  36. } from '@/api/shoping.js';
  37. import {
  38. getCartList,
  39. } from '@/api/cart.js';
  40. export default {
  41. components: {
  42. list
  43. },
  44. data() {
  45. return {
  46. // 当前选中的滑块
  47. current: 0,
  48. // 门店信息
  49. info: {
  50. logo: '',
  51. title: ''
  52. },
  53. ratio: '', //页面比例信息
  54. search: '' ,//店铺搜索商品
  55. total: 0
  56. //商店详情
  57. };
  58. },
  59. onShow() {
  60. this.loadCart();
  61. },
  62. onLoad(pt) {
  63. // 保存商户id
  64. this.info.id = pt.merid;
  65. this.getShoping();
  66. },
  67. onReachBottom(e) {
  68. // 底部加载数据
  69. this.$refs.dataList.loadData();
  70. },
  71. onReady() {
  72. // 保存商家id
  73. this.$refs.dataList.mer_id = this.info.id;
  74. // 加载分类
  75. this.$refs.dataList.loadCateList();
  76. let obj = this;
  77. let query = uni.createSelectorQuery();
  78. // 获取页面比例
  79. query
  80. .select('.content')
  81. .fields({
  82. size: true
  83. },
  84. e => {
  85. // 保存比例
  86. this.ratio = e.width / 750;
  87. }
  88. )
  89. .exec();
  90. },
  91. computed: {
  92. // 计算图标大小
  93. iconSize() {
  94. return 28 * this.ratio;
  95. }
  96. },
  97. methods: {
  98. navtab() {
  99. uni.switchTab({
  100. url: '/pages/cart/cart'
  101. })
  102. },
  103. async loadCart() {
  104. let obj = this;
  105. getCartList({
  106. type: 0
  107. })
  108. .then(function(e) {
  109. obj.total = e.data.valid.length;
  110. })
  111. .catch(function(e) {
  112. console.log(e);
  113. });
  114. },
  115. //获取商店信息
  116. getShoping() {
  117. let obj = this;
  118. getShoping({}, this.info.id)
  119. .then(function({
  120. data
  121. }) {
  122. obj.info = data.info;
  123. obj.$refs.dataList.iszy = obj.info.is_triple;
  124. // 加载数据
  125. obj.$refs.dataList.loadData();
  126. })
  127. .catch(e => {
  128. console.log(e);
  129. });
  130. },
  131. // 滑块切换时触发方法
  132. changeIndex(e) {
  133. this.current = e.current;
  134. },
  135. // 搜索确认事件
  136. confirm(e) {
  137. this.$refs.dataList.keyword = e.detail.value;
  138. this.$refs.dataList.page = 1;
  139. this.$refs.dataList.loadData('refresh');
  140. },
  141. // 回退功能
  142. backUrl() {
  143. uni.navigateBack();
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. .cart {
  150. position: fixed;
  151. right: 30rpx;
  152. bottom: 60rpx;
  153. .cart-icon {
  154. width: 150rpx;
  155. height: 150rpx;
  156. }
  157. .text {
  158. background-color: $color-red;
  159. color: #FFF;
  160. position: absolute;
  161. top: 0;
  162. right: 0;
  163. width: 40rpx;
  164. height: 40rpx;
  165. z-index: 999;
  166. text-align: center;
  167. border-radius: 99rpx;
  168. }
  169. }
  170. page,
  171. .content {
  172. height: 100%;
  173. }
  174. .varHeight {
  175. height: var(--status-bar-height);
  176. }
  177. .banner {
  178. .shpingInfo {
  179. padding: 30rpx $page-row-spacing;
  180. .logoBox {
  181. .logo {
  182. height: 90rpx;
  183. width: 90rpx;
  184. border-radius: 50%;
  185. }
  186. .shopingTitle {
  187. padding-left: 20rpx;
  188. color: #ffffff;
  189. font-size: $font-lg;
  190. }
  191. }
  192. .shopingExit {}
  193. }
  194. .serachBox,
  195. .shpingInfo {
  196. z-index: 999;
  197. }
  198. .bgImg {
  199. position: absolute;
  200. top: 0;
  201. left: 0;
  202. width: 100%;
  203. height: 100%;
  204. }
  205. .serachBox {
  206. padding: 0 $page-row-spacing;
  207. padding-bottom: 20rpx;
  208. width: 100%;
  209. .serachInput {
  210. background-color: rgba($color: #f1f1f1, $alpha: 0.5);
  211. border-radius: 100rpx;
  212. padding: 10rpx 25rpx;
  213. width: 100%;
  214. .search {
  215. padding-left: 20rpx;
  216. width: 100%;
  217. color: #ffffff;
  218. font-size: 28rpx;
  219. }
  220. }
  221. }
  222. }
  223. </style>