zuoyouliandongA.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view class="u-wrap">
  3. <view class="linesp"></view>
  4. <view class="linesp"></view>
  5. <view class="linesp"></view>
  6. <view class="u-menu-wrap">
  7. <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop"
  8. :scroll-into-view="itemId">
  9. <view v-for="(item,index) in shangpinfenlei" :key="index" class="u-tab-item" :class="[current == index ? 'u-tab-item-active' : '']"
  10. @tap.stop="swichMenu(index)">
  11. <text class="u-line-1">{{item.name}}</text>
  12. </view>
  13. <view style="height: 140rpx;"></view>
  14. </scroll-view>
  15. <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box">
  16. <view class="page-view">
  17. <view v-if="listType===2" class="item-container">
  18. <view class="thumb-box2" v-for="(item1, index1) in shangpinlist" :key="index1" >
  19. <view class="thumb-boxR">
  20. <netImage class="goodimage" width="180" height="140" :mysrc="item1.image" mymode="scaleToFill" v-on:Emyimageclick="shangpinsl(item1.id)"></netImage>
  21. <view class="msText">
  22. <text class="dianpuming" @click="shangpinsl(item1.id)">{{item1.name}}</text>
  23. <!-- <view class="buyBTSB" @click="shangpinsl(item1.id)">
  24. <view class="buyBT" style="background-color: #FEFCED;">
  25. <image class="xingxing" src="/static/images/dianzan@3x.png" mode="heightFix"></image>
  26. <text class="peisongsuoming" style="color: #988233;">本店销量第3名</text>
  27. </view>
  28. <text class="peisongsuoming">{{$t('comp.yuexiao')}}300+</text>
  29. </view> -->
  30. <view class="buyBT">
  31. <text class="peisongsuoming detailtextV">{{item1.introduce}}</text>
  32. <!-- <view class="contensbgg" v-for="(skus,inx) in shangpingoumaiS[current][index1].sku">
  33. <text class="youhuixinxi" @click="editSKU(current,index1)">{{skus}}</text>
  34. </view> -->
  35. </view>
  36. <view v-if="shangpingoumaiS[current][index1]" class="buyBTSB">
  37. <text class="peisongsuoming">{{$formPr(item1.price)}}{{$t('locale.huobidw')}}</text>
  38. <view class="rconten">
  39. <!-- <uni-icons class="imageR" custom-prefix="custom-icon" color="#00A6FF" type="cart" size="30" @click="editSKU(index1)"></uni-icons> -->
  40. <image v-if="shangpingoumaiS[current][index1].shuliang>0" class="imageRJ" src="/static/images/jian@3x.png" mode="aspectFit" @click="jiangouwuche(index1)"></image>
  41. <text v-if="shangpingoumaiS[current][index1].shuliang>0" class="textR">{{shangpingoumaiS[current][index1].shuliang}}</text>
  42. <image class="imageR" src="/static/images/plus-circle-fill@3x.png" mode="aspectFit" @click="editSKU(index1)"></image>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="linesp"></view>
  48. </view>
  49. </view>
  50. <view style="height: 140rpx;"></view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. <view class="bottomfloatV">
  55. <view class="buyBT" >
  56. <image class="gouwuche" :src="gouwcheimg" mode="aspectFit"></image>
  57. <text class="peisongsuoming">{{notext}}</text>
  58. <text class="qjs" :style="{backgroundColor:gwbcolor,color:gwbTcolor}" @click="gotojiesuan">{{$t('comp.qujiesuan')}}</text>
  59. </view>
  60. </view>
  61. <popViewGG :show="showpop" :showbotom="false" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  62. <foodxuangou style="width:100%;max-height: 70vh" :food="spindexSP" v-on:Ejiagouwuche="jiagouwuche"></foodxuangou>
  63. </popViewGG>
  64. </view>
  65. </template>
  66. <script>
  67. import api from "@/pages/api/api.js";
  68. export default {
  69. props: {
  70. mendid:0,
  71. mendname:'',
  72. userid:0,
  73. isShangjia:0
  74. },
  75. data() {
  76. return {
  77. gouwcheimg:'/static/images/gouwuh@3x.png',
  78. notext:this.$t('comp.weixgsp'),
  79. goumaijine:0,
  80. gwbcolor:'darkgray',
  81. gwbTcolor:'black',
  82. scrollTop: 0, //tab标题的滚动条位置
  83. current: 0, // 当前分类值
  84. spindex:0,//当前分类商品操作INDEX
  85. spindexSP:'',//当前分类商品操作INDEX对应商品
  86. itemId: '', // 栏目右边scroll-view用于滚动的id
  87. shangpinfenlei: [],
  88. shangpinlist: [],
  89. shangpingoumaiS:[],
  90. goumaishangpin:[],
  91. scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
  92. listType:2,
  93. skuGuige:[],
  94. showpop:false,
  95. gouwuche:{
  96. foodlist:[],
  97. mendid:'',
  98. userid:'',
  99. mendname:''
  100. }
  101. }
  102. },
  103. created() {
  104. this.refleashdata();
  105. },
  106. methods: {
  107. refleashdata(){
  108. var gwc = uni.getStorageSync('gouwuche');
  109. if(''==gwc||null==gwc||undefined==gwc){
  110. this.gouwuche={
  111. foodlist:[],
  112. mendid:'',
  113. userid:'',
  114. mendname:''
  115. };
  116. this.tongjigouwuche();
  117. }
  118. else{
  119. this.gouwuche = JSON.parse(gwc);
  120. this.tongjigouwuche();
  121. }
  122. //this.shangpingoumaiS=[];
  123. this.getmendianshangpinFL(this.mendid);
  124. },
  125. // 点击左边的栏目切换
  126. async swichMenu(index) {
  127. this.scrollRightTop = 0;
  128. this.current = index;
  129. this.getmendianshangpinList(this.shangpinfenlei[index].id);
  130. },
  131. // jiangouwuche(index){
  132. // var goumail=this.shangpingoumaiS[this.current][index].shuliang;
  133. // var oldgoumail = goumail;
  134. // var danjia = this.shangpingoumaiS[this.current][index].shangpin.price;
  135. // if(goumail>0){
  136. // goumail=goumail-1;
  137. // }
  138. // var yidongjine=(goumail-oldgoumail)*danjia;
  139. // this.goumaijine = this.goumaijine+yidongjine;
  140. // this.shangpingoumaiS[this.current][index].shuliang=goumail;
  141. // this.gengxingouwuche(this.shangpingoumaiS[this.current][index]);
  142. // console.log(this.shangpingoumaiS);
  143. // var temp=[];
  144. // for (var i=0;i<this.shangpinlist.length;i++) {
  145. // temp.push(this.shangpinlist[i]);
  146. // }
  147. // this.shangpinlist=temp;
  148. // },
  149. jiangouwuche(e){
  150. //跳转购物车
  151. uni.navigateTo({
  152. url:'/pages/OrderList/buy/gouwuche'
  153. })
  154. },
  155. jiagouwuche(e){
  156. var gwc = uni.getStorageSync('gouwuche');
  157. if(''==gwc||null==gwc||undefined==gwc){
  158. this.gouwuche={
  159. foodlist:[],
  160. mendid:'',
  161. userid:'',
  162. mendname:''
  163. };
  164. }
  165. else{
  166. this.gouwuche = JSON.parse(gwc);
  167. }
  168. this.dowithshangpinList(this.shangpinlist);
  169. this.tongjigouwuche();
  170. var temp=[];
  171. for (var i=0;i<this.shangpinlist.length;i++) {
  172. temp.push(this.shangpinlist[i]);
  173. }
  174. this.shangpinlist=temp;
  175. this.showpop=false;
  176. },
  177. jinger(){
  178. if(this.goumaijine>0){
  179. this.notext=this.$formPr(this.goumaijine)+this.$t('locale.huobidw');
  180. console.log(this.notext);
  181. this.gwbcolor='green';
  182. this.gwbTcolor='white';
  183. this.gouwcheimg='/static/images/gouwu@3x.png';
  184. this.showbt=true;
  185. }
  186. if(this.goumaijine==0){
  187. this.gwbcolor='darkgray';
  188. this.gwbTcolor='black';
  189. this.notext=this.$t('comp.weixgsp');
  190. this.gouwcheimg='/static/images/gouwuh@3x.png';
  191. this.showbt=false;
  192. }
  193. },
  194. shangpinsl(id){
  195. //选择商品
  196. uni.navigateTo({
  197. url:'/pages/shanpinxungou/shangpin/shangpinxiangqing?id='+id+'&isShangjia='+this.isShangjia
  198. })
  199. },
  200. tongjigouwuche(){
  201. this.goumaijine = 0;
  202. if(this.gouwuche.mendid==this.mendid){
  203. for(var j=0;j<this.gouwuche.foodlist.length;j++){
  204. var sp = this.gouwuche.foodlist[j];
  205. this.goumaijine = this.goumaijine+sp.number*(sp.price+sp.otherPrice);
  206. }
  207. }
  208. this.jinger();
  209. },
  210. gotojiesuan(){
  211. if(!this.showbt){
  212. uni.showToast({
  213. title: this.$t('comp.qingxzsp'),
  214. icon: 'none',
  215. duration: 2500
  216. })
  217. return;
  218. }
  219. var token = uni.getStorageSync("token");
  220. //console.log('2222',token)
  221. if(token == '' || token == undefined || token == null){
  222. uni.navigateTo({
  223. url:'/pages/UserCenter/LoginView'
  224. })
  225. return;
  226. }
  227. uni.setStorageSync('JSfoodlist',this.gouwuche.foodlist);
  228. uni.navigateTo({
  229. url:'/pages/OrderList/buy/jiesuanYe?mendid='+this.mendid+'&userid='+this.userid
  230. })
  231. },
  232. editSKU(index){
  233. this.spindex=index;
  234. var sp = this.shangpingoumaiS[this.current][index];
  235. //this.skuGuige=sp.shangpin.sku;
  236. this.spindexSP = sp;
  237. this.showpop=true;
  238. console.log('<<<<<<',this.shangpinlist[index]);
  239. //this.$refs.popup.open();
  240. },
  241. chooseCancel(){
  242. this.showpop=false;
  243. },
  244. getmendianshangpinFL(id){
  245. api('getmendianshangpinFL',{
  246. id:id
  247. },res=>{
  248. this.shangpinfenlei=res.data.data;
  249. if(this.shangpinfenlei.length>0){
  250. this.getmendianshangpinList(this.shangpinfenlei[0].id);
  251. }
  252. },failc=>{
  253. //console.log('getadvertis----',failc)
  254. })
  255. },
  256. getmendianshangpinList(id){
  257. api('getmendianshangpinList',{
  258. id:id
  259. },r=>{
  260. this.dowithshangpinList(r.data.data);
  261. this.shangpinlist=r.data.data;
  262. },failc=>{
  263. //console.log('getadvertis----',failc)
  264. })
  265. },
  266. dowithshangpinList(shangpinlist){
  267. if(this.shangpingoumaiS.length==0){
  268. for(var i=0;i<this.shangpinfenlei.length;i++){
  269. this.shangpingoumaiS.push([]);
  270. }
  271. }
  272. this.shangpingoumaiS[this.current]=[];
  273. for(var j=0;j<shangpinlist.length;j++){
  274. var shuliang = this.tongbugouwuchexinxi(shangpinlist[j]);
  275. var otherPrice = this.getotherPrice(shangpinlist[j].foodSku);
  276. var tempSKU = this.gettempSKU(shangpinlist[j].foodSku);
  277. var tempsp={
  278. "shangpin":shangpinlist[j],
  279. "sku":tempSKU,
  280. "otherPrice":otherPrice,
  281. "shuliang":shuliang
  282. }
  283. this.shangpingoumaiS[this.current].push(tempsp);
  284. }
  285. },
  286. tongbugouwuchexinxi(sp){
  287. var tempshuliang = 0;
  288. for(var i=0;i<this.gouwuche.foodlist.length;i++){
  289. if(this.gouwuche.foodlist[i].id == sp.id){
  290. tempshuliang = tempshuliang + this.gouwuche.foodlist[i].number;
  291. }
  292. }
  293. return tempshuliang;
  294. },
  295. gettempSKU(foodSku){
  296. var selectsku=[];
  297. for(var i=0;i<foodSku.length;i++){
  298. if(foodSku[i].objects.length>0){
  299. for(var j=0;j<foodSku[i].objects.length;j++){
  300. if(foodSku[i].objects[j].state==1){
  301. selectsku.push(foodSku[i].objects[j].name);
  302. }
  303. }
  304. }
  305. }
  306. return selectsku;
  307. },
  308. getotherPrice(foodSku){
  309. var jiner=0;
  310. for(var i=0;i<foodSku.length;i++){
  311. if(foodSku[i].objects.length>0){
  312. for(var j=0;j<foodSku[i].objects.length;j++){
  313. if(foodSku[i].objects[j].state==1){
  314. jiner=jiner+parseFloat(foodSku[i].objects[j].price);
  315. }
  316. }
  317. }
  318. }
  319. return parseFloat(jiner);
  320. }
  321. }
  322. }
  323. </script>
  324. <style scoped>
  325. .u-wrap {
  326. height: calc(60vh);
  327. display: flex;
  328. flex-direction: column;
  329. }
  330. .linesp{
  331. height: 4rpx;
  332. background-color:#f6f6f6;
  333. }
  334. .u-menu-wrap {
  335. flex: 1;
  336. display: flex;
  337. overflow: hidden;
  338. }
  339. .u-tab-view {
  340. width: 100vw;
  341. height: 100vh;
  342. }
  343. .u-tab-item {
  344. height: 110rpx;
  345. background: #f6f6f6;
  346. box-sizing: border-box;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. font-size: 26rpx;
  351. color: #444;
  352. font-weight: 400;
  353. line-height: 1;
  354. }
  355. .u-tab-item-active {
  356. position: relative;
  357. color: #000;
  358. font-size: 30rpx;
  359. font-weight: 600;
  360. background: #fff;
  361. }
  362. .u-tab-item-active::before {
  363. content: "";
  364. position: absolute;
  365. border-left: 4px solid $u-type-primary;
  366. height: 32rpx;
  367. left: 0;
  368. top: 39rpx;
  369. }
  370. .u-tab-view {
  371. height: 100%;
  372. }
  373. .right-box {
  374. }
  375. .page-view {
  376. padding: 16rpx;
  377. padding-left: 0rpx;
  378. }
  379. .class-item {
  380. margin-bottom: 30rpx;
  381. background-color: #fff;
  382. padding: 16rpx;
  383. border-radius: 8rpx;
  384. padding-left: 0rpx;
  385. }
  386. .class-item:last-child {
  387. min-height: 100vh;
  388. }
  389. .item-title {
  390. font-size: 26rpx;
  391. color: $u-main-color;
  392. font-weight: bold;
  393. }
  394. .item-menu-name {
  395. font-weight: normal;
  396. font-size: 24rpx;
  397. color: $u-main-color;
  398. }
  399. .item-container {
  400. display: flex;
  401. flex-wrap: wrap;
  402. width: 67vw;
  403. }
  404. .thumb-box {
  405. width: 33vw;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. flex-direction: column;
  410. margin-top: 20rpx;
  411. }
  412. .item-menu-image {
  413. width: 120rpx;
  414. height: 120rpx;
  415. }
  416. .thumb-box2 {
  417. width: 67vw;
  418. display: flex;
  419. justify-content: flex-start;
  420. margin-top: 10rpx;
  421. background-color: #f6f6f6;
  422. }
  423. .thumb-boxR {
  424. width: 67vw;
  425. display: flex;
  426. align-items: center;
  427. justify-content: flex-start;
  428. flex-direction: row;
  429. margin-bottom:20rpx;
  430. background-color: white;
  431. }
  432. .goodimage{
  433. padding-top: 4rpx;
  434. }
  435. .msText{
  436. width: 500rpx;
  437. padding-left: 10rpx;
  438. font-size: 22rpx;
  439. line-height: 32rpx;
  440. }
  441. .dianpuming{
  442. font-size: 30rpx;
  443. line-height: 32rpx;
  444. height: 32rpx;
  445. font-weight: bold;
  446. overflow: hidden;
  447. text-overflow: ellipsis;
  448. display: -webkit-box;
  449. -webkit-line-clamp: 2;
  450. -webkit-box-orient: vertical;
  451. }
  452. .peisongsuoming{
  453. font-size: 26rpx;
  454. line-height: 38rpx;
  455. height: 38rpx;
  456. color: dimgray;
  457. }
  458. .detailtextV{
  459. width: 90%;
  460. height: 80rpx;
  461. overflow: hidden;
  462. text-overflow: ellipsis;
  463. display: -webkit-box;
  464. -webkit-line-clamp: 2;
  465. -webkit-box-orient: vertical;
  466. }
  467. .buyBTSB{
  468. display: flex;
  469. flex-direction: row;
  470. justify-content:space-between;
  471. align-items: center;
  472. }
  473. .buyBT{
  474. display: flex;
  475. flex-direction: row;
  476. justify-content:flex-start;
  477. align-items: center;
  478. }
  479. .contensbgg{
  480. display: flex;
  481. flex-wrap: wrap;
  482. justify-content:flex-start;
  483. align-items:center;
  484. }
  485. .youhuixinxi{
  486. margin-right: 10rpx;
  487. font-size: 26rpx;
  488. padding: 6rpx;
  489. color: lightcoral;
  490. border: 2rpx solid lightcoral;
  491. border-radius: 8rpx;
  492. }
  493. .xingxing{
  494. width: 34rpx;
  495. height: 34rpx;
  496. }
  497. .rconten{
  498. margin-left: auto;
  499. display:flex;
  500. flex-direction: row;
  501. align-items: center;
  502. }
  503. .imageRJ{
  504. width: 56rpx;
  505. height: 56rpx;
  506. margin-right: 8rpx;
  507. }
  508. .imageR{
  509. width: 50rpx;
  510. height: 50rpx;
  511. margin-right: 30rpx;
  512. }
  513. .textR{
  514. margin-left: 6rpx;
  515. margin-right: 6rpx;
  516. }
  517. .bottomfloatV{
  518. position: fixed;
  519. flex-direction: row;
  520. align-items: center;
  521. left: 0;
  522. right: 0;
  523. bottom: 0;
  524. z-index: 999;
  525. background-color: whitesmoke;
  526. height: 140rpx;
  527. }
  528. .gouwuche{
  529. width: 120rpx;
  530. height: 120rpx;
  531. }
  532. .qjs{
  533. border-radius: 8rpx;
  534. padding: 6rpx;
  535. margin-left: auto;
  536. margin-right: 30rpx;
  537. font-size: 32rpx;
  538. height: 100rpx;
  539. line-height: 100rpx;
  540. }
  541. .querenBt{
  542. margin-top: 30rpx;
  543. width: 100%;
  544. height: 60rpx;
  545. line-height: 60rpx;
  546. padding: 10rpx;
  547. border-radius: 20rpx;
  548. border: solid crimson;
  549. border-width: 0px 0px 6rpx 0px;
  550. text-align: center;
  551. justify-content: center;
  552. background-color: #00A6FF;
  553. color: white;
  554. box-shadow: -4rpx 4rpx 2rpx 5rpx lightgrey;
  555. }
  556. </style>