shangpinList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <template>
  2. <view>
  3. <view class="toptalbarCtv">
  4. <customNav :shownav="true" :title="$t('goods.meishiss')" titledetl=""></customNav>
  5. <view :style="{top: statusBarHeight+'rpx'}">
  6. <uni-search-bar class="searchbar" :placeholder="$t('goods.meishiss')" cancelButton="none" locateButton="always" v-on:confirm="searchAct"></uni-search-bar>
  7. <view class="contentInRowC" style="padding-top: 10rpx;padding-bottom: 10rpx;background-color: #efeff4;;">
  8. <text class="tipyLBt" :style="BtState==1?'background-color:white;color:black':''" @click="BtStatesl(1)">{{$t('index.goodslist')}}</text>
  9. <text class="tipyRBt" :style="BtState==2?'background-color:white;color:black':''" @click="BtStatesl(2)">{{$t('index.mendianliebiao')}}</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view style="margin-top: 380rpx;">
  14. <view v-if="!listShow" class="keywordct">
  15. <text style="margin-top: 40rpx;font-weight: bold;">{{$t('goods.shousuojl')}}</text>
  16. <view v-if="!listShow" class="keywordLct" >
  17. <image style="width: 50rpx;height:50rpx; margin-right: 16rpx;" src="/static/images/time@3x.png" mode="widthFix"></image>
  18. <view class="keywordL" v-for="keyword in searchKeyWord">
  19. <label class="" @click="seachwordSl(keyword)">{{keyword}}</label>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-if="!listShow" class="keywordct">
  24. <text style="margin-top: 40rpx;font-weight: bold;">{{$t('goods.remenss')}}</text>
  25. <view class="keywordLct" >
  26. <view class="keywordL" v-for="keyword in defKeyWord">
  27. <label class="" @click="seachwordSl(keyword)">{{keyword}}</label>
  28. </view>
  29. </view>
  30. </view>
  31. <view v-if="listShow&&BtState==1" style="background-color:#efeff4;">
  32. <!-- to 属性携带参数跳转详情页面,当前只为参考 -->
  33. <view class="contentColumnC" style="width: 94%;margin-left: 3%;" v-for="(item,index) in food" :key="index">
  34. <view class="item_content2" >
  35. <view class="buyctT" @click="gotoDetail(item.id)">
  36. <myImage class="goodimage" :mysrc="item.image" mymode="scaleToFill"></myImage>
  37. <view class="msText">
  38. <view class="contentColumn">
  39. <view>
  40. <text class="dianpuming">{{item.name}}</text>
  41. </view>
  42. <text class="peisongsuoming">{{item.introduce}}</text>
  43. </view>
  44. <view class="buyBTSB">
  45. <text class="peisongsuoming">{{$formPr(item.price)}}{{$t('locale.huobidw')}}</text>
  46. <text class="peisongsuoming">{{yuexiaoliang(0)}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view style="width: 94%;background-color:papayawhip;height: 2rpx;margin-left: 3%;"></view>
  51. <view class="buyct" @click="gotomendian(item.store.id)">
  52. <!-- <myImage class="sjimage" :mysrc="item.store.logo" mymode="scaleToFill"></myImage> -->
  53. <netImage width="120" height="120" bradius="60" :mysrc="item.store.logo" mymode="scaleToFill"></netImage>
  54. <view class="msText">
  55. <text class="dianpuming">{{item.store.posName}}</text>
  56. <view class="buyBT">
  57. <image class="xingxing" src="/static/images/xingxing@3x.png" mode="aspectFit"></image>
  58. <text class="pingfentext">4.9</text>
  59. <text class="mainyuntishi">{{$t('index.manX')}} {{$formPr(item.store.posPrice)}}{{$t('locale.huobidw')}}</text>
  60. </view>
  61. <view class="buyBT">
  62. <text class="shijiantishi">{{$t('mend.waisongsj')}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view v-if="listShow&&BtState==2" style="background-color:#efeff4;">
  70. <!-- to 属性携带参数跳转详情页面,当前只为参考 -->
  71. <view class="contentColumn" style="width:700rpx;margin-left:25rpx;margin-top: 20rpx;" v-for="(item,index) in store" :key="index">
  72. <view class="buyct" @click="gotomendian(item.id)">
  73. <!-- <myImage class="sjimage" :mysrc="item.store.logo" mymode="scaleToFill"></myImage> -->
  74. <netImage width="120" height="120" bradius="60" :mysrc="item.logo" mymode="scaleToFill"></netImage>
  75. <view class="msText">
  76. <text class="dianpuming">{{item.posName}}</text>
  77. <view class="buyBT">
  78. <image class="xingxing" src="/static/images/xingxing@3x.png" mode="aspectFit"></image>
  79. <text class="pingfentext">4.9</text>
  80. <text class="mainyuntishi">{{$t('index.manX')}} {{$formPr(item.posPrice)}}{{$t('locale.huobidw')}}</text>
  81. </view>
  82. <view class="buyBT">
  83. <text class="shijiantishi">{{$t('mend.waisongsj')}}</text>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import api from "@/pages/api/api.js"
  94. export default {
  95. components: {},
  96. data() {
  97. return {
  98. statusBarHeight:0,
  99. store:[],
  100. food:[],
  101. BtState:1,
  102. loading:false,
  103. searchKeyWord:[],
  104. defKeyWord:['卤味','鸡排','香酥鸡','粥','冰饮','铁板饭','盖浇饭','牛排','炸鸡','烤鸭'],
  105. listShow:false,
  106. };
  107. },
  108. onLoad() {
  109. var systemInfo = uni.getSystemInfoSync();
  110. this.statusBarHeight=systemInfo.statusBarHeight*2+100;
  111. var data = uni.getStorageSync("searchKeyWord" );
  112. if(null==data||''==data||undefined==data){
  113. this.searchKeyWord=[];
  114. }
  115. else{
  116. this.searchKeyWord = JSON.parse(data);
  117. }
  118. var str = this.$t('goods.shousoreci');
  119. this.defKeyWord = str.split(',');
  120. },
  121. methods: {
  122. yuexiaoliang(sul){
  123. if(sul==0){
  124. sul = Math.floor(Math.random()*(300))+50;
  125. }
  126. var str = '';
  127. var language = uni.getStorageSync('language');
  128. if(language=='yuenan'){
  129. str = 'Bán '+sul+'+ mỗi tháng';
  130. }
  131. else if(language=='zh-Hans'){
  132. str =this.$t('comp.yuexiao')+sul+'+';
  133. }
  134. else if(language=='zh-Hant'){
  135. str =this.$t('comp.yuexiao')+sul+'+';
  136. }
  137. return str;
  138. },
  139. BtStatesl(index){
  140. this.BtState=index;
  141. },
  142. gotoDetail(e){
  143. console.log(e);
  144. uni.navigateTo({
  145. url:'/pages/shanpinxungou/shangpin/shangpinxiangqing?id='+e
  146. })
  147. },
  148. gotomendian(id){
  149. uni.navigateTo({
  150. url:'/pages/shanpinxungou/shangjia/merchantdetail?id='+id+'&isShangjia=0'
  151. })
  152. },
  153. seachwordSl(keyword){
  154. console.log(keyword);
  155. this.searchGoods(keyword);
  156. },
  157. searchAct(e){
  158. console.log(e)
  159. this.searchGoods(e.value);
  160. var index=-1;
  161. for(var i=0;i<this.searchKeyWord.length;i++){
  162. if(this.searchKeyWord[i]==e.value){
  163. index=i;
  164. break
  165. }
  166. }
  167. if(index<0){
  168. this.searchKeyWord.push(e.value);
  169. if(this.searchKeyWord.length>10){
  170. this.searchKeyWord.shift();
  171. }
  172. }
  173. else{
  174. this.searchKeyWord.push(e.value);
  175. this.searchKeyWord.splice(index, 1)
  176. }
  177. var temp = JSON.stringify(this.searchKeyWord);
  178. uni.setStorageSync("searchKeyWord",temp);
  179. },
  180. searchGoods(keyword){
  181. var language = uni.getStorageSync('language');
  182. var lang=0;
  183. if(language=='yuenan'){//0
  184. lang=0;
  185. }
  186. if(language=='zh-Hans'){//2
  187. lang=2;
  188. }
  189. if(language=='zh-Hant'){//3
  190. lang=3;
  191. }
  192. api('searchfor',{
  193. page:1,
  194. size:20,
  195. keyword:keyword,
  196. language:lang
  197. },res=>{
  198. console.log(res)
  199. if(res.data.code==200){
  200. this.store = res.data.data.store;
  201. this.food = res.data.data.food;
  202. this.listShow=true;
  203. }
  204. },failc=>{
  205. //console.log('getadvertis----',failc)
  206. })
  207. },
  208. },
  209. /**
  210. * 下拉刷新回调函数
  211. */
  212. onPullDownRefresh() {
  213. },
  214. /**
  215. * 上拉加载回调函数
  216. */
  217. onReachBottom() {
  218. }
  219. };
  220. </script>
  221. <style lang="scss">
  222. @import '@/common/uni-ui.scss';
  223. page {
  224. display: flex;
  225. flex-direction: column;
  226. box-sizing: border-box;
  227. background-color: #efeff4;
  228. min-height: 100%;
  229. height: auto;
  230. }
  231. .toptalbarCtv{
  232. position: fixed;
  233. background-color: #40AE36;
  234. left: 0;
  235. right: 0;
  236. top: 0;
  237. z-index: 999;
  238. }
  239. .searchbar{
  240. background-color: #40AE36;
  241. margin-top: 20rpx;
  242. }
  243. .tipyLBt{
  244. font-size: 28rpx;
  245. width: 40%;
  246. border-radius: 6px 0px 0px 6px;
  247. border: 2rpx solid lightgray;
  248. line-height: 64rpx;
  249. text-align: center;
  250. color: darkgray;
  251. }
  252. .tipyRBt{
  253. font-size: 28rpx;
  254. width: 40%;
  255. border-radius: 0px 6px 6px 0px;
  256. border: 2rpx solid lightgray;
  257. line-height: 64rpx;
  258. text-align: center;
  259. color: darkgray;
  260. }
  261. .keywordct{
  262. display: flex;
  263. flex-direction: column;
  264. padding: 0 40rpx;
  265. }
  266. .keywordLct{
  267. display: flex;
  268. flex-wrap: wrap;
  269. justify-content:flex-start;
  270. align-items:center;
  271. }
  272. .keywordL{
  273. padding-left: 30rpx;
  274. padding-right: 30rpx;
  275. padding-top: 8rpx;
  276. padding-bottom: 8rpx;
  277. margin-right: 20rpx;
  278. margin-top: 20rpx;
  279. margin-bottom: 20rpx;
  280. font-size: 28rpx;
  281. text-align: center;
  282. box-sizing: border-box;
  283. border: 2rpx solid lightgray;
  284. border-radius: 30rpx;
  285. }
  286. .item_content2{
  287. background:white;
  288. height: 356rpx;
  289. margin-top: 20rpx;
  290. border-radius: 10rpx;
  291. border: 2rpx solid lightgray;
  292. }
  293. .item_content{
  294. background:white;
  295. height: 520rpx;
  296. margin-top: 20rpx;
  297. border-radius: 10rpx;
  298. border: 2rpx solid lightgray;
  299. }
  300. .buyctT{
  301. height: 160rpx;
  302. padding: 14rpx;
  303. display: flex;
  304. flex-direction: row;
  305. }
  306. .buyct{
  307. height: 140rpx;
  308. padding: 14rpx;
  309. display: flex;
  310. flex-direction: row;
  311. background-color: snow;
  312. }
  313. .goodimage{
  314. width: 160rpx;
  315. height: 160rpx;
  316. background-color: whitesmoke;
  317. }
  318. .sjimage{
  319. width: 120rpx;
  320. height: 120rpx;
  321. background-color: whitesmoke;
  322. }
  323. .buyBTSB{
  324. display: flex;
  325. flex-direction: row;
  326. justify-content:space-between;
  327. align-items: center;
  328. }
  329. .buyBT{
  330. display: flex;
  331. flex-direction: row;
  332. justify-content:left;
  333. align-items: center;
  334. }
  335. .msText{
  336. width: 530rpx;
  337. padding-left: 10rpx;
  338. font-size: 22rpx;
  339. line-height: 32rpx;
  340. }
  341. .dianpuming{
  342. font-size: 30rpx;
  343. line-height: 32rpx;
  344. font-weight: bold;
  345. overflow: hidden;
  346. text-overflow: ellipsis;
  347. display: -webkit-box;
  348. -webkit-line-clamp: 2;
  349. -webkit-box-orient: vertical;
  350. }
  351. .peisongsuoming{
  352. font-size: 26rpx;
  353. line-height: 38rpx;
  354. height: 38rpx;
  355. color: dimgray;
  356. overflow: hidden;
  357. text-overflow: ellipsis;
  358. display: -webkit-box;
  359. -webkit-line-clamp: 1;
  360. -webkit-box-orient: vertical;
  361. }
  362. .xingxing{
  363. width: 40rpx;
  364. height: 40rpx;
  365. }
  366. .pingfentext{
  367. font-size: 26rpx;
  368. line-height: 40rpx;
  369. height: 40rpx;
  370. color:sandybrown;
  371. }
  372. .mainyuntishi{
  373. margin-left: 30rpx;
  374. padding-left: 8rpx;
  375. padding-right: 8rpx;
  376. font-size: 26rpx;
  377. line-height: 40rpx;
  378. height: 40rpx;
  379. color: dimgray;
  380. background-color: burlywood;
  381. border-radius: 4rpx;
  382. }
  383. .shijiantishi{
  384. margin-left: 30rpx;
  385. font-size: 26rpx;
  386. line-height: 40rpx;
  387. height: 40rpx;
  388. color: dimgray;
  389. }
  390. .youhuixinxi{
  391. margin-right: 10rpx;
  392. font-size: 26rpx;
  393. line-height: 40rpx;
  394. height: 40rpx;
  395. color: lightcoral;
  396. border: 2rpx solid lightcoral;
  397. border-radius: 8rpx;
  398. }
  399. .title{
  400. padding-top: 8rpx;
  401. padding-left: 8rpx;
  402. width: 100%;
  403. text-align: left;
  404. font-weight:initial;
  405. overflow: hidden;
  406. text-overflow: ellipsis;
  407. display: -webkit-box;
  408. -webkit-line-clamp: 1;
  409. -webkit-box-orient: vertical;
  410. }
  411. .Dishes{
  412. width: 100%;
  413. text-align: left;
  414. padding-left: 8rpx;
  415. color: darkgray;
  416. }
  417. .price{
  418. text-align: left;
  419. //line-height: 28rpx;
  420. color: black;
  421. padding-left: 8rpx;
  422. }
  423. </style>