search.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <app-layout>
  3. <view class="search dir-left-nowrap cross-centers">
  4. <view class="search-view">
  5. <input id="search" @confirm='toSearch' confirm-type='search' placeholder="请输入商品名称搜索" v-model="keyword" type="text" focus @focus="getFocus=true">
  6. <image v-if="getFocus && keyword.length > 0" @click="clearSearch" class="search-clear" src="/static/image/icon/delete-yuan.png"></image>
  7. </view>
  8. <view @click="toSearch" class="search-btn">搜索</view>
  9. </view>
  10. <view class="main-center no-result" v-if="list.length == 0 && searchResult">
  11. <view class="dir-left-nowrap cross-center">
  12. <image class="box-grow-0 empty" src="/static/image/icon/empty.png"></image>
  13. <view class="box-grow-1">
  14. <view>抱歉,没有相关商品</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="list">
  19. <view class="item" v-for="item in list" :key="item.id">
  20. <app-composition :theme="getTheme" @click="show(item)" @look="toDetail(item)" :item="item" :large="true">
  21. <template>
  22. <view class="look-goods main-center cross-center">
  23. <view>套餐商品</view>
  24. <image src="/static/image/icon/icon-down.png"></image>
  25. </view>
  26. </template>
  27. </app-composition>
  28. </view>
  29. </view>
  30. <view @click="close" class="dialog-bg" v-if="showGoods">
  31. <view @click.stop="" class="dialog" :style="{'bottom':height +'px'}" :animation="animationData">
  32. <view class="dialog-title main-between cross-center">
  33. <view @click="toDetail(detail)" class="toBuy dir-left-nowrap cross-center">
  34. <image :class="getTheme + '-m-back ' + getTheme " src="/static/image/icon/goods-cart.png"></image>
  35. <view :class="getTheme + '-m-text ' + getTheme ">去购买套餐</view>
  36. </view>
  37. <view class="close">
  38. <image @click="close" src="/static/image/icon/close.png"></image>
  39. </view>
  40. </view>
  41. <view class="dialog-goods-list">
  42. <view @click.stop="toGoods(item.goods_id)" class="dialog-goods dir-left-nowrap" v-for="item in detail.host_list" :key="item.id">
  43. <image :src="item.cover_pic"></image>
  44. <view>
  45. <view class="t-omit-two goods-name">{{item.name}}</view>
  46. <view class="goods-price" :class="getTheme + '-m-text ' + getTheme ">¥{{item.min_price}}{{item.max_price != item.min_price ? '~¥'+item.max_price : ''}}</view>
  47. </view>
  48. </view>
  49. <view @click.stop="toGoods(item.goods_id)" class="dialog-goods dir-left-nowrap" v-for="item in detail.goods_list" :key="item.id">
  50. <image :src="item.cover_pic"></image>
  51. <view>
  52. <view class="t-omit-two goods-name">{{item.name}}</view>
  53. <view class="goods-price" :class="getTheme + '-m-text ' + getTheme ">¥{{item.min_price}}{{item.max_price != item.min_price ? '~¥'+item.max_price : ''}}</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </app-layout>
  60. </template>
  61. <script>
  62. import {mapGetters, mapState} from "vuex";
  63. import appComposition from'../../../components/basic-component/app-composition/app-composition.vue';
  64. export default {
  65. data() {
  66. return {
  67. list: [],
  68. keyword: '',
  69. choose_list: [],
  70. detail: {},
  71. animationData: {},
  72. height: 0,
  73. searchResult: false,
  74. searchMode: true,
  75. getFocus: true,
  76. showGoods: false,
  77. }
  78. },
  79. components: {
  80. 'app-composition': appComposition,
  81. },
  82. computed: {
  83. ...mapGetters('mallConfig', {
  84. getTheme: 'getTheme',
  85. })
  86. },
  87. methods: {
  88. show(e) {
  89. this.detail = e;
  90. this.showGoods = true;
  91. var animation = uni.createAnimation({
  92. duration: 1000,
  93. timingFunction: 'ease',
  94. })
  95. this.animation = animation
  96. animation.translateY(this.height).step()
  97. this.animationData = animation.export();
  98. },
  99. close() {
  100. this.detail = {};
  101. this.showGoods = false;
  102. },
  103. toDetail(item) {
  104. this.close();
  105. uni.navigateTo({
  106. url: '/plugins/composition/detail/detail?composition_id=' + item.id
  107. });
  108. },
  109. toGoods(id) {
  110. uni.navigateTo({
  111. url: '/pages/goods/goods?id=' + id
  112. });
  113. },
  114. // updateList(e) {
  115. // this.list = e;
  116. // },
  117. // choose(row,type) {
  118. // let that = this;
  119. // if(type == 1) {
  120. // for(let i in that.choose_list) {
  121. // if(that.choose_list[i].type == 2) {
  122. // if(that.choose_list[i].host_list[0].id == row.id) {
  123. // that.choose_list[i].host_list[0] = row;
  124. // }else {
  125. // for(let x in that.choose_list[i].goods_list) {
  126. // if(that.choose_list[i].goods_list[x].id == row.id) {
  127. // that.choose_list[i].goods_list[x] = row;
  128. // }
  129. // }
  130. // }
  131. // }
  132. // }
  133. // uni.setStorage({
  134. // key: "composition",
  135. // data: that.choose_list
  136. // })
  137. // uni.navigateBack();
  138. // }else {
  139. // let index = -1;
  140. // for(let i in that.choose_list) {
  141. // if(that.choose_list[i].id == row.id) {
  142. // index = i;
  143. // }
  144. // }
  145. // if(index > -1) {
  146. // that.choose_list[index] = row;
  147. // }
  148. // uni.setStorage({
  149. // key: "composition",
  150. // data: that.choose_list
  151. // })
  152. // uni.navigateBack();
  153. // }
  154. // },
  155. clearSearch() {
  156. this.keyword = '';
  157. this.list = [];
  158. this.searchResult = false;
  159. },
  160. toSearch() {
  161. let that = this;
  162. uni.showLoading({
  163. mask: true,
  164. title: '搜索中...',
  165. });
  166. that.$request({
  167. url: that.$api.composition.index,
  168. data: {
  169. keyword: that.keyword
  170. }
  171. }).then(response=>{
  172. uni.hideLoading();
  173. that.searchResult = true;
  174. if(response.code == 0) {
  175. that.list = response.data.list;
  176. // for(let i in that.list) {
  177. // that.list[i].choose = false;
  178. // for(let idx in that.list[i].goods_list) {
  179. // that.list[i].goods_list[idx].choose_attr = null;
  180. // if(that.list[i].type == 2) {
  181. // that.list[i].host_list[0].choose_attr = null;
  182. // that.list[i].host_list[0].opacity = 1;
  183. // that.list[i].goods_list[idx].choose_goods = false;
  184. // that.list[i].host_list[0].choose_goods = false;
  185. // }
  186. // }
  187. // }
  188. }else {
  189. uni.hideLoading();
  190. uni.showToast({
  191. title: response.msg,
  192. icon: 'none',
  193. duration: 1000
  194. });
  195. }
  196. }).catch(response => {
  197. that.$hideLoading();
  198. });
  199. },
  200. },
  201. onLoad() {
  202. let that = this;
  203. uni.getSystemInfo({
  204. success: function (res) {
  205. that.height = -res.screenHeight;
  206. }
  207. })
  208. },
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .list {
  213. margin-top: #{108rpx};
  214. .item {
  215. margin: 0 #{24rpx} #{20rpx};
  216. background-color: #fff;
  217. border-radius: #{16rpx};
  218. padding: #{24rpx};
  219. padding-bottom: #{16rpx};
  220. .look-goods {
  221. margin-top: #{8rpx};
  222. border-radius: #{8rpx};
  223. height: #{48rpx};
  224. width: #{288rpx};
  225. font-size: #{24rpx};
  226. color: #666666;
  227. background-color: #f7f7f7;
  228. image {
  229. width: #{18rpx};
  230. height: #{10rpx};
  231. margin-left: #{16rpx};
  232. }
  233. }
  234. }
  235. }
  236. .no-result {
  237. height: #{156rpx};
  238. padding: #{28rpx} 0;
  239. margin-top: #{88rpx};
  240. font-size: $uni-font-size-general-one;
  241. background-color: #ffffff;
  242. .text {
  243. color: $uni-general-color-two;
  244. }
  245. .empty {
  246. width: #{100rpx};
  247. height: #{100rpx};
  248. display: block;
  249. margin-right: #{40rpx};
  250. }
  251. }
  252. .search {
  253. width: #{750rpx};
  254. height: #{88rpx};
  255. position: fixed;
  256. top: 0;
  257. left: 0;
  258. z-index: 100;
  259. background-color: #efeff4;
  260. padding: #{15rpx} 0;
  261. padding-left: #{24rpx};
  262. box-sizing: border-box;
  263. .search-view {
  264. flex-shrink: 0;
  265. position: relative;
  266. width: #{626rpx};
  267. height: #{88-30rpx};
  268. background-color: white;
  269. border-radius: #{29rpx};
  270. .search-clear {
  271. position: absolute;
  272. right: #{15rpx};
  273. top: #{14rpx};
  274. width: #{30rpx};
  275. height: #{30rpx};
  276. z-index: 100;
  277. }
  278. input {
  279. box-sizing: border-box;
  280. padding: #{0 70rpx 0 30rpx};
  281. font-size: #{26rpx};
  282. height: #{58rpx};
  283. line-height: #{58rpx};
  284. }
  285. .image {
  286. width: #{20rpx};
  287. height: #{20rpx};
  288. margin-right: #{11rpx};
  289. }
  290. .text {
  291. font-size: #{26rpx};
  292. color: #999999;
  293. }
  294. }
  295. .search-btn {
  296. width: #{100rpx};
  297. height: #{58rpx};
  298. line-height: #{58rpx};
  299. text-align: center;
  300. font-size: #{28rpx};
  301. color: #666;
  302. }
  303. }
  304. .dialog-bg {
  305. position: fixed;
  306. bottom: 0;
  307. left: 0;
  308. width: 100%;
  309. height: 100%;
  310. background-color: rgba(0,0,0,.3);
  311. z-index: 202;
  312. .dialog {
  313. width: 100%;
  314. position: fixed;
  315. left: 0;
  316. z-index: 210;
  317. background-color: #fff;
  318. border-top-left-radius: #{16rpx};
  319. border-top-right-radius: #{16rpx};
  320. .dialog-title {
  321. padding: #{36rpx} #{24rpx} #{24rpx};
  322. font-size: #{32rpx};
  323. color: #353535;
  324. .toBuy {
  325. font-size: #{28rpx};
  326. image {
  327. width: #{36rpx};
  328. height: #{36rpx};
  329. margin-right: #{12rpx};
  330. display: block;
  331. }
  332. }
  333. .close {
  334. image {
  335. width: #{36rpx};
  336. height: #{36rpx};
  337. }
  338. }
  339. }
  340. .dialog-goods-list {
  341. padding: 0 #{24rpx};
  342. max-height: #{750rpx};
  343. overflow-y: auto;
  344. .dialog-goods {
  345. font-size: #{32rpx};
  346. position: relative;
  347. padding: #{28rpx} 0;
  348. border-top: #{2rpx} solid #e2e2e2;
  349. image {
  350. width: #{180rpx};
  351. height: #{180rpx};
  352. margin-right: #{24rpx};
  353. border-radius: #{8rpx};
  354. }
  355. .goods-name {
  356. color: #353535;
  357. width: #{498rpx};
  358. }
  359. .goods-price {
  360. position: absolute;
  361. bottom: #{50rpx};
  362. left: #{204rpx};
  363. }
  364. }
  365. .dialog-goods:first-of-type {
  366. border-top: 0;
  367. }
  368. }
  369. }
  370. }
  371. </style>