shangpinList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. <!-- <image class="sjimage" src="/static/defimages/324.png" mode="aspectFit"></image> -->
  53. <myImage class="sjimage" :mysrc="item.store.image" mymode="scaleToFill"></myImage>
  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="contentColumnC" style="width:700rpx;margin-left:25rpx;" v-for="(item,index) in store" :key="index">
  72. <view class="item_content" @click="gotomendian(item.id)">
  73. <netImage style="background-color: whitesmoke;" width="700" height="410" :mysrc="item.image"></netImage>
  74. <view class="title textfontB3">
  75. <text >{{item.posName}}</text>
  76. </view>
  77. <view class="contentInRowS">
  78. <view class="price textfontB5">
  79. <text>{{$t('index.manX')}} {{$formPr(item.posPrice)}}{{$t('locale.huobidw')}}</text>
  80. </view>
  81. <view class="contentInRowR" style="margin-right: 8rpx;">
  82. <text v-if="item.state==0&&item.offShelf=='0'" style="color: green;">{{$t('mend.stateyy')}}</text>
  83. <text v-if="item.state==1&&item.offShelf=='0'" style="color: crimson;">{{$t('mend.statedy')}}</text>
  84. <text v-if="item.offShelf=='1'" style="color: darkgray;">{{$t('mend.mendianyxj')}}</text>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import api from "@/pages/api/api.js"
  95. export default {
  96. components: {},
  97. data() {
  98. return {
  99. statusBarHeight:0,
  100. store:[],
  101. food:[],
  102. BtState:1,
  103. loading:false,
  104. searchKeyWord:[],
  105. defKeyWord:['卤味','鸡排','香酥鸡','粥','冰饮','铁板饭','盖浇饭','牛排','炸鸡','烤鸭'],
  106. listShow:false,
  107. };
  108. },
  109. onLoad() {
  110. var systemInfo = uni.getSystemInfoSync();
  111. this.statusBarHeight=systemInfo.statusBarHeight*2+100;
  112. var data = uni.getStorageSync("searchKeyWord" );
  113. if(null==data||''==data||undefined==data){
  114. this.searchKeyWord=[];
  115. }
  116. else{
  117. this.searchKeyWord = JSON.parse(data);
  118. }
  119. var str = this.$t('goods.shousoreci');
  120. this.defKeyWord = str.split(',');
  121. },
  122. methods: {
  123. yuexiaoliang(sul){
  124. if(sul==0){
  125. sul = Math.floor(Math.random()*(300))+50;
  126. }
  127. var str = '';
  128. var language = uni.getStorageSync('language');
  129. if(language=='yuenan'){
  130. str = 'Bán '+sul+'+ mỗi tháng';
  131. }
  132. else if(language=='zh-Hans'){
  133. str =this.$t('comp.yuexiao')+sul+'+';
  134. }
  135. else if(language=='zh-Hant'){
  136. str =this.$t('comp.yuexiao')+sul+'+';
  137. }
  138. return str;
  139. },
  140. BtStatesl(index){
  141. this.BtState=index;
  142. },
  143. gotoDetail(e){
  144. console.log(e);
  145. uni.navigateTo({
  146. url:'/pages/shanpinxungou/shangpin/shangpinxiangqing?id='+e
  147. })
  148. },
  149. gotomendian(id){
  150. uni.navigateTo({
  151. url:'/pages/shanpinxungou/shangjia/shangjiaView?id='+id+'&isShangjia=0'
  152. })
  153. },
  154. seachwordSl(keyword){
  155. console.log(keyword);
  156. this.searchGoods(keyword);
  157. },
  158. searchAct(e){
  159. console.log(e)
  160. this.searchGoods(e.value);
  161. var index=-1;
  162. for(var i=0;i<this.searchKeyWord.length;i++){
  163. if(this.searchKeyWord[i]==e.value){
  164. index=i;
  165. break
  166. }
  167. }
  168. if(index<0){
  169. this.searchKeyWord.push(e.value);
  170. if(this.searchKeyWord.length>10){
  171. this.searchKeyWord.shift();
  172. }
  173. }
  174. else{
  175. this.searchKeyWord.push(e.value);
  176. this.searchKeyWord.splice(index, 1)
  177. }
  178. var temp = JSON.stringify(this.searchKeyWord);
  179. uni.setStorageSync("searchKeyWord",temp);
  180. },
  181. searchGoods(keyword){
  182. var language = uni.getStorageSync('language');
  183. var lang=0;
  184. if(language=='yuenan'){//0
  185. lang=0;
  186. }
  187. if(language=='zh-Hans'){//2
  188. lang=2;
  189. }
  190. if(language=='zh-Hant'){//3
  191. lang=3;
  192. }
  193. api('searchfor',{
  194. page:1,
  195. size:20,
  196. keyword:keyword,
  197. language:lang
  198. },res=>{
  199. console.log(res)
  200. if(res.data.code==200){
  201. this.store = res.data.data.store;
  202. this.food = res.data.data.food;
  203. this.listShow=true;
  204. }
  205. },failc=>{
  206. //console.log('getadvertis----',failc)
  207. })
  208. },
  209. },
  210. /**
  211. * 下拉刷新回调函数
  212. */
  213. onPullDownRefresh() {
  214. },
  215. /**
  216. * 上拉加载回调函数
  217. */
  218. onReachBottom() {
  219. }
  220. };
  221. </script>
  222. <style lang="scss">
  223. @import '@/common/uni-ui.scss';
  224. page {
  225. display: flex;
  226. flex-direction: column;
  227. box-sizing: border-box;
  228. background-color: #efeff4;
  229. min-height: 100%;
  230. height: auto;
  231. }
  232. .toptalbarCtv{
  233. position: fixed;
  234. background-color: #40AE36;
  235. left: 0;
  236. right: 0;
  237. top: 0;
  238. z-index: 999;
  239. }
  240. .searchbar{
  241. background-color: #40AE36;
  242. margin-top: 20rpx;
  243. }
  244. .tipyLBt{
  245. font-size: 28rpx;
  246. width: 40%;
  247. border-radius: 6px 0px 0px 6px;
  248. border: 2rpx solid lightgray;
  249. line-height: 64rpx;
  250. text-align: center;
  251. color: darkgray;
  252. }
  253. .tipyRBt{
  254. font-size: 28rpx;
  255. width: 40%;
  256. border-radius: 0px 6px 6px 0px;
  257. border: 2rpx solid lightgray;
  258. line-height: 64rpx;
  259. text-align: center;
  260. color: darkgray;
  261. }
  262. .keywordct{
  263. display: flex;
  264. flex-direction: column;
  265. padding: 0 40rpx;
  266. }
  267. .keywordLct{
  268. display: flex;
  269. flex-wrap: wrap;
  270. justify-content:flex-start;
  271. align-items:center;
  272. }
  273. .keywordL{
  274. padding-left: 30rpx;
  275. padding-right: 30rpx;
  276. padding-top: 8rpx;
  277. padding-bottom: 8rpx;
  278. margin-right: 20rpx;
  279. margin-top: 20rpx;
  280. margin-bottom: 20rpx;
  281. font-size: 28rpx;
  282. text-align: center;
  283. box-sizing: border-box;
  284. border: 2rpx solid lightgray;
  285. border-radius: 30rpx;
  286. }
  287. .item_content2{
  288. background:white;
  289. height: 356rpx;
  290. margin-top: 20rpx;
  291. border-radius: 10rpx;
  292. border: 2rpx solid lightgray;
  293. }
  294. .item_content{
  295. background:white;
  296. height: 520rpx;
  297. margin-top: 20rpx;
  298. border-radius: 10rpx;
  299. border: 2rpx solid lightgray;
  300. }
  301. .buyctT{
  302. height: 160rpx;
  303. padding: 14rpx;
  304. display: flex;
  305. flex-direction: row;
  306. }
  307. .buyct{
  308. height: 140rpx;
  309. padding: 14rpx;
  310. display: flex;
  311. flex-direction: row;
  312. background-color: snow;
  313. }
  314. .goodimage{
  315. width: 160rpx;
  316. height: 160rpx;
  317. background-color: whitesmoke;
  318. }
  319. .sjimage{
  320. width: 120rpx;
  321. height: 120rpx;
  322. background-color: whitesmoke;
  323. }
  324. .buyBTSB{
  325. display: flex;
  326. flex-direction: row;
  327. justify-content:space-between;
  328. align-items: center;
  329. }
  330. .buyBT{
  331. display: flex;
  332. flex-direction: row;
  333. justify-content:left;
  334. align-items: center;
  335. }
  336. .msText{
  337. width: 530rpx;
  338. padding-left: 10rpx;
  339. font-size: 22rpx;
  340. line-height: 32rpx;
  341. }
  342. .dianpuming{
  343. font-size: 30rpx;
  344. line-height: 32rpx;
  345. font-weight: bold;
  346. overflow: hidden;
  347. text-overflow: ellipsis;
  348. display: -webkit-box;
  349. -webkit-line-clamp: 2;
  350. -webkit-box-orient: vertical;
  351. }
  352. .peisongsuoming{
  353. font-size: 26rpx;
  354. line-height: 38rpx;
  355. height: 38rpx;
  356. color: dimgray;
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. display: -webkit-box;
  360. -webkit-line-clamp: 1;
  361. -webkit-box-orient: vertical;
  362. }
  363. .xingxing{
  364. width: 40rpx;
  365. height: 40rpx;
  366. }
  367. .pingfentext{
  368. font-size: 26rpx;
  369. line-height: 40rpx;
  370. height: 40rpx;
  371. color:sandybrown;
  372. }
  373. .mainyuntishi{
  374. margin-left: 30rpx;
  375. padding-left: 8rpx;
  376. padding-right: 8rpx;
  377. font-size: 26rpx;
  378. line-height: 40rpx;
  379. height: 40rpx;
  380. color: dimgray;
  381. background-color: burlywood;
  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>