goodsDet.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  1. <template>
  2. <view class="detail_all pages">
  3. <!-- banner -->
  4. <view class="detail-banner">
  5. <!-- <image :src="goodsDet.goodsPicture" mode=""></image> -->
  6. <swiper class="swiper" :autoplay="true" interval="2000" duration="500" :circular="true"
  7. style="width: 100%;height: 410rpx;">
  8. <swiper-item v-for="(item,index) in goodsDet.goodsPicture" :key='index'>
  9. <image :src="item" mode="scaleToFill" style="width: 100%;"></image>
  10. </swiper-item>
  11. </swiper>
  12. </view>
  13. <!-- 详情 -->
  14. <view class="info">
  15. <view class="info-box">
  16. <view class="info-box-con">
  17. <view class="info-box-con-name">
  18. {{goodsDet.goodsName}}
  19. </view>
  20. <view class="info-box-con-cart" v-if="goodsDet.goodsLabel && goodsDet.goodsLabel.length">
  21. <view v-for="(item,index) in goodsDet.goodsLabel">{{item}}</view>
  22. <!-- <view>香辣</view>
  23. <view>本店销量第一</view> -->
  24. </view>
  25. <view class="info-box-con-num">
  26. 已售{{goodsDet.sales}}
  27. </view>
  28. <view class="info-box-con-select">
  29. <view class="info-box-con-select-l">
  30. <view>
  31. <span>¥</span>
  32. <text>{{goodsDet.goodsMoney}}</text>
  33. </view>
  34. <view>
  35. <span>打包费</span>
  36. <text>¥{{goodsDet.packMoney}}/份</text>
  37. </view>
  38. </view>
  39. <view class="info-box-con-select-r" @click="skuShow=true">
  40. 加入购物车
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- tabs -->
  47. <view class="tabs">
  48. <view class="tabs-box">
  49. <view class="tabs-box-item" @click="switchTba(index)" v-for="(item,index) in tabs" :key="index">
  50. {{item.name}}
  51. <view v-show="current==index"></view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="current==0">
  56. <view class="goodsInfo">
  57. <view class="goodsInfo-box">
  58. <view class="goodsInfo-box-c">
  59. <view class="goodsInfo-box-title">
  60. 产品描述
  61. </view>
  62. <view class="goodsInfo-box-c-item">
  63. <u-parse :html="goodsDet.goodsDescribe"></u-parse>
  64. </view>
  65. <!-- <view class="goodsInfo-box-c-item" v-for="(item,index) in infoList" :key="index">
  66. <view class="">
  67. {{item.name}}
  68. </view>
  69. <view class="">
  70. {{item.con}}
  71. </view>
  72. </view> -->
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 图片详情 -->
  77. <view class="imgInfo" v-if="goodsDet.goodsParticularsPicture && goodsDet.goodsParticularsPicture.length">
  78. <view class="imgInfo-box">
  79. <view class="imgInfo-box-title">
  80. 图片详情
  81. </view>
  82. <view class="imgInfo-box-img">
  83. <image v-for="(item,index) in goodsDet.goodsParticularsPicture" :key='index' :src="item"
  84. mode="widthFix"></image>
  85. </view>
  86. <!-- <view class="detail_describe" v-if="goodsDet.goodsParticularsPicture.length">
  87. <view class="detail_describe_ce">
  88. <view class="detail_describe_text">商品详情图</view>
  89. <image v-for="(item,index) in goodsDet.goodsParticularsPicture" :key='index' :src="item"
  90. style="width: 100%;" mode="scaleToFill"></image>
  91. </view>
  92. </view> -->
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 评论 -->
  97. <view v-if="current==1">
  98. <view class="pingjia">
  99. <view class="pingjia-box">
  100. <view class="pingjia-box-title">
  101. 商品评价
  102. </view>
  103. <view class="" style="width: 600rpx;" v-if="current==1">
  104. <view class="pingjia-box-btn">
  105. <u-button hover-class='none' @click="sel(0)" type="primary" shape="circle" size="mini"
  106. :plain="false" :custom-style="count==0?customStyle:customStyle1">全部评论</u-button>
  107. <u-button hover-class='none' @click="sel(1)" type="primary" shape="circle" size="mini"
  108. :plain="false" :custom-style="count==1?customStyle:customStyle1">
  109. 好评({{EvaluateData.goodReputation?EvaluateData.goodReputation:0}})</u-button>
  110. <u-button hover-class='none' @click="sel(2)" type="primary" shape="circle" size="mini"
  111. :plain="false" :custom-style="count==2?customStyle:customStyle1">
  112. 中评({{EvaluateData.mediumReview?EvaluateData.mediumReview:0}})</u-button>
  113. <u-button hover-class='none' @click="sel(3)" type="primary" shape="circle" size="mini"
  114. :plain="false" :custom-style="count==3?customStyle:customStyle1">
  115. 差评({{EvaluateData.negativeComment?EvaluateData.negativeComment:0}})</u-button>
  116. </view>
  117. <view class="pingjia-box-item" v-for="(item, index) in EvaluateList"
  118. :key='index'>
  119. <view class="flex justify-between align-center">
  120. <view class="flex align-center">
  121. <u-avatar :src="item.avatar" size="65"></u-avatar>
  122. <view class=" margin-left-sm" style="line-height: 46upx;font-size: 24rpx;">
  123. {{item.userName?item.userName:'匿名'}}
  124. </view>
  125. <view class="flex margin-left-sm">
  126. <u-icon v-for="ite in item.score" :key='ite' color="#FCD202" name="star-fill">
  127. </u-icon>
  128. </view>
  129. </view>
  130. <view class="timess">{{item.createTime}}</view>
  131. </view>
  132. <view class="margin-top-sm">{{item.evaluateMessage}}</view>
  133. <view class="pinglunImg" v-if="item.pictures!=undefined && item.pictures">
  134. <view class="pinglunImg-box flex justify-between flex-wrap">
  135. <image style="margin-bottom: 20rpx;" @click="yuanlan(item.pictures==undefined?[]:item.pictures.split(','),index2)" v-for="(item2,index2) in item.pictures==undefined?[]:item.pictures.split(',')" :src="item2" mode=""></image>
  136. <image style="margin-bottom: 20rpx;width: 140rpx;height: 0;" src="" mode=""></image>
  137. <image style="margin-bottom: 20rpx;width: 140rpx;height: 0;" src="" mode=""></image>
  138. </view>
  139. </view>
  140. <view class="margin-top-sm" v-if="item.shopReplyMessage">
  141. <view class="flex align-center">
  142. <view class=" flex align-center text-df" style="color: #999999;">
  143. <view class="text-df">商家回复:</view>{{item.shopReplyMessage}}
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. <empty v-if="!EvaluateList.length"></empty>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <!-- <view class="detail">
  154. <view class="detail_text">{{goodsDet.goodsName}}</view>
  155. <view class="detail_biao" v-if="goodsDet.goodsLabel.length">
  156. <view class="detail_biao_sty" v-for="(ite, ind) in goodsDet.goodsLabel" :key='ind'>{{ite}}</view>
  157. </view>
  158. <text style="font-size: 22upx;color: #999999;" v-if="goodsDet.packMoney&&goodsDet.packMoney>0">打包費:{{goodsDet.packMoney}}元/1份</text>
  159. <view class="margin-top" v-for="(item,index) in attrList" :key="index">
  160. <view class="text-bold text-black">{{item.value}}</view>
  161. <view class="flex margin-tb-sm flex-wrap">
  162. <view v-for="(ite, ind) in item.detail" :key="ind" @click="skuSel(ite,index,ind)"
  163. class="margin-bottom-sm">
  164. <view class="btn" :class="item.goodsId == index && item.attrId == ind?'active': ''">
  165. {{ite.name}}
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. </view> -->
  171. <!-- 产品描述 -->
  172. <!-- <view class="detail_describe">
  173. <view class="detail_describe_ce">
  174. <view class="detail_describe_text">产品描述</view>
  175. <u-parse :html="goodsDet.goodsDescribe"></u-parse>
  176. </view>
  177. </view> -->
  178. <view style="height: 180rpx;"></view>
  179. <!-- 加购 -->
  180. <view class="settlement" @click="isPopupShow" >
  181. <view class="settlement_img">
  182. <image src="../../../static/images/index/diancan.png" mode=""></image>
  183. <view class="settlement_hot">{{goodsNum}}</view>
  184. </view>
  185. <view class="settlement_le">
  186. <text>¥</text>{{totalPrice}}
  187. </view>
  188. <view class="settlement_ri" @click.stop="goConfirm()">去结算</view>
  189. </view>
  190. <!-- 购物车弹窗 -->
  191. <u-popup v-model="popupShow" mode="bottom" border-radius="20">
  192. <view class="padding">
  193. <view class="flex justify-between align-center margin-bottom-sm">
  194. <view class="text-bold text-black text-df">已选餐品</view>
  195. <view class="flex align-center">
  196. <image src="../../../static/images/index/delete.png" style="width: 28rpx;height: 31rpx;"
  197. mode=""></image>
  198. <text class="margin-left-xs" @click="empty">清空购物车</text>
  199. </view>
  200. </view>
  201. <scroll-view scroll-y='true' class="popup">
  202. <view v-for="(item,ind) in goodsList.orderGoodsList[0]" :key='ind'>
  203. <view class="flex align-center margin-tb-sm">
  204. <image :src="item.goodsPicture[0]"
  205. style="width: 96rpx;height: 96rpx;border-radius: 10rpx;">
  206. </image>
  207. <view class="margin-left-sm">
  208. <view>{{item.goodsName}}</view>
  209. <view v-if="item.skuMessage">{{item.skuMessage}}</view>
  210. </view>
  211. </view>
  212. <view class="flex justify-between align-center">
  213. <view class="text-bold text-sm">¥<text class="text-lg">{{item.goodsPrice}}</text>
  214. </view>
  215. <view class="flex align-center justify-between">
  216. <view @click.stop="noAdd(item,ind)">
  217. <image src="../../../static/images/index/jian.png"
  218. style="width: 54rpx;height: 54rpx;"></image>
  219. </view>
  220. <view class="text-center margin-lr-xs">{{item.goodsNum}}</view>
  221. <view @click.stop="add(item,ind)">
  222. <image src="../../../static/images/index/add.png"
  223. style="width: 50rpx;height: 50rpx;"></image>
  224. </view>
  225. </view>
  226. </view>
  227. </view>
  228. </scroll-view>
  229. </view>
  230. <view class="settlement1 margin-top-lg">
  231. <view class="settlement_img">
  232. <image src="../../../static/images/index/diancan.png" mode=""></image>
  233. <view class="settlement_hot">{{goodsNum}}</view>
  234. </view>
  235. <view class="settlement_le">
  236. <text>¥</text>{{totalPrice}}
  237. </view>
  238. <view class="settlement_ri" @click.stop="goConfirm()">去结算</view>
  239. </view>
  240. </u-popup>
  241. <!-- 选择规格弹窗 -->
  242. <u-popup v-model="skuShow" mode="center" :closeable='true' border-radius="20">
  243. <view style="width: 700rpx;">
  244. <view class="text-center text-lg text-bold padding-tb">{{goodsDet.goodsName}}</view>
  245. <view class="margin-top-sm padding-lr" v-for="(item,index) in attrList" :key="index">
  246. <view class="text-bold text-black">{{item.value}}</view>
  247. <view class="flex margin-tb-sm flex-wrap">
  248. <view v-for="(ite, ind) in item.detail" :key="ind" @click="skuSel(ite,index,ind)"
  249. class="margin-bottom-sm">
  250. <view class="skuBtn"
  251. :class="item.goodsId == index && item.attrId == ind?'active': ''">
  252. {{ite.name}}
  253. </view>
  254. </view>
  255. </view>
  256. </view>
  257. <view class="flex justify-between padding-lr padding-top">
  258. <view>
  259. <view class="text-xl text-bold text-black"><text class="text-sm">¥</text>{{price}}
  260. </view>
  261. <view class="detail_describe_text2">{{checkString}}</view>
  262. </view>
  263. <u-number-box :disabled-input="true" v-model="value" :min="1" @change="valChange"></u-number-box>
  264. </view>
  265. <view class="detail_account_bottom padding">
  266. <view class="detail_account_bottom_le" @click="payment()">立即购买</view>
  267. <view class="detail_account_bottom_ri" @click="orderSel(2)">加入购物车</view>
  268. </view>
  269. </view>
  270. </u-popup>
  271. <!-- <view class="detail_account">
  272. <view class="detail_account_top">
  273. <view class="detail_account_top_le">
  274. <view class="detail_account_text"><text>¥</text>{{price}}</view>
  275. <view class="detail_describe_text2">{{checkString}}</view>
  276. </view>
  277. </view>
  278. <view class="detail_account_bottom">
  279. <view class="detail_account_bottom_le" @click="payment()">立即购买</view>
  280. <view class="detail_account_bottom_ri" @click="orderSel(2)">加入购物车</view>
  281. </view>
  282. </view> -->
  283. </view>
  284. </template>
  285. <script>
  286. import empty from '@/components/empty.vue'
  287. export default {
  288. components: {
  289. empty
  290. },
  291. data() {
  292. return {
  293. customStyle: {
  294. color: '#FFA200',
  295. background: '#FFFBE5',
  296. marginRight: '20rpx',
  297. border: 0
  298. },
  299. customStyle1: {
  300. color: '#333333',
  301. background: '#F2F2F2',
  302. marginRight: '20rpx',
  303. border: 0
  304. },
  305. EvaluateData: {},
  306. shopDet: {},
  307. skuShow: false,
  308. totalPrice: 0,
  309. goodsNum: 0,
  310. infoList:[
  311. {
  312. name:'原料',
  313. con:'土豆'
  314. },
  315. {
  316. name:'份量',
  317. con:'1人份'
  318. },
  319. {
  320. name:'荤素',
  321. con:'素菜'
  322. },
  323. {
  324. name:'菜系',
  325. con:'川菜'
  326. },
  327. {
  328. name:'口味',
  329. con:'咸香'
  330. },
  331. {
  332. name:'辅料',
  333. con:'姜,辣椒,蒜,葱'
  334. }
  335. ],
  336. current:0,
  337. tabs: [{
  338. id: 0,
  339. name: '详情'
  340. },
  341. {
  342. id: 1,
  343. name: '评价'
  344. }
  345. ],
  346. goodsList: {
  347. orderGoodsList: [
  348. []
  349. ]
  350. },
  351. popupShow: false,
  352. goodsId: '',
  353. goodsDet: {},
  354. skuId: '',
  355. skuMessage: '',
  356. skuList: [],
  357. attrList: [],
  358. checkString: '',
  359. checkStateList: [],
  360. CheckattrValue: false,
  361. userId: '',
  362. value: 1,
  363. shopId: '',
  364. price: 0,
  365. echoSkuList: [],
  366. echoSku: [],
  367. isEchoSku: {},
  368. orderType: 2,
  369. orderId: '',
  370. evaluatePage: 1,
  371. evaluateLimit: 10,
  372. grade: '',
  373. count: 0,
  374. EvaluateList:[],
  375. backType:'',
  376. }
  377. },
  378. onLoad(option) {
  379. console.log(option)
  380. this.userId = uni.getStorageSync('userId')
  381. this.goodsId = option.goodsId
  382. this.shopId = option.shopId
  383. this.orderId = option.orderId ? option.orderId : ''
  384. this.orderType = option.orderType ? option.orderType : 2
  385. this.backType = option.backType ? option.backType : ''
  386. uni.showLoading({
  387. title: '加载中...'
  388. })
  389. this.getData()
  390. this.getEchoOrder()
  391. },
  392. onShow() {
  393. this.userId = uni.getStorageSync('userId')
  394. this.getOrderList();
  395. },
  396. onReachBottom: function() {
  397. if (this.current == 1) {
  398. this.evaluatePage = this.evaluatePage + 1;
  399. this.getEvaluateList()
  400. }
  401. },
  402. methods: {
  403. // 去结算
  404. goConfirm() {
  405. if (!this.userId) {
  406. uni.navigateTo({
  407. url: '/pages/public/login'
  408. })
  409. return
  410. }
  411. console.log(this.goodsList)
  412. if (this.goodsList && this.goodsList.orderGoodsList[0].length > 0) {
  413. uni.navigateTo({
  414. url: '/pages/index/shop/confirmOrder?shopId=' + this.shopId + '&orderType=' + this
  415. .orderType
  416. })
  417. } else {
  418. uni.showToast({
  419. title: '请先添加商品',
  420. icon: "none"
  421. })
  422. }
  423. },
  424. // 预览图片
  425. yuanlan(arr,index){
  426. uni.previewImage({
  427. urls:arr,
  428. current:index
  429. })
  430. },
  431. switchTba(index){
  432. this.current = index
  433. if(index==0){
  434. this.getData()
  435. }else{
  436. this.evaluatePage =1;
  437. this.getEvaluateList()
  438. }
  439. },
  440. sel(e) {
  441. this.grade = e
  442. this.count = e
  443. this.evaluatePage = 1
  444. this.getEvaluateList()
  445. },
  446. // 获取评论列表
  447. getEvaluateList() {
  448. let data = {
  449. goodsId: this.goodsId,
  450. shopId: this.shopId,
  451. page: this.evaluatePage,
  452. limit: this.evaluateLimit,
  453. grade: this.grade
  454. }
  455. this.$Request.get("/app/goods/selectEvaluateByShopId", data).then(res => {
  456. if (res.code == 0 && res.data) {
  457. this.EvaluateData = res.data
  458. if (this.evaluatePage == 1) {
  459. this.EvaluateList = res.data.pageUtils.list
  460. } else {
  461. this.EvaluateList = [...this.EvaluateList, ...res.data.pageUtils.list]
  462. }
  463. }
  464. });
  465. },
  466. // 展示购物车弹窗
  467. isPopupShow() {
  468. console.log(this.goodsList, '677')
  469. if (this.goodsList && this.goodsList.orderGoodsList && this.goodsList.orderGoodsList[0].length > 0) {
  470. this.popupShow = true
  471. } else {
  472. uni.showToast({
  473. title: '请先添加商品',
  474. icon: "none"
  475. })
  476. }
  477. },
  478. getEchoOrder() {
  479. let data = {
  480. shopId: this.shopId,
  481. goodsId: this.goodsId
  482. }
  483. this.$Request.get("/app/order/echoOrder", data).then(res => {
  484. if (res.code == 0 && res.data) {
  485. this.echoSkuList = res.data
  486. this.echoSku = res.data[0].skuMessage.split(',')
  487. }
  488. });
  489. },
  490. valChange(e) {
  491. console.log('当前值为: ' + e.value)
  492. this.value = e.value
  493. },
  494. // 立即购买
  495. payment() {
  496. let token = uni.getStorageSync('token')
  497. if (!token) {
  498. uni.navigateTo({
  499. url: '/pages/public/login'
  500. })
  501. return
  502. }
  503. if (this.attrList.length) {
  504. if (this.checkString == '' || !this.CheckattrValue) {
  505. this.$queue.showToast('请选择正确的商品规格');
  506. return;
  507. }
  508. }
  509. let data = {
  510. goodsId: this.goodsDet.goodsId,
  511. skuMessage: this.skuMessage,
  512. skuId: this.skuId,
  513. num: this.value,
  514. orderType: this.orderType,
  515. shopId: this.shopId,
  516. }
  517. this.$Request.post("/app/order/buyGoods", data).then(res => {
  518. if (res.code == 0) {
  519. uni.navigateTo({
  520. url: '/pages/index/shop/payOrder?orderId=' + res.data + '&orderType=' + this
  521. .orderType
  522. })
  523. } else {
  524. this.$queue.showToast(res.msg);
  525. }
  526. })
  527. },
  528. // 添加数量
  529. add(item, index) {
  530. // this.count++;
  531. console.log(item, index)
  532. this.goodsList.orderGoodsList[0][index].goodsNum++
  533. let data = {
  534. orderGoodsId: this.goodsList.orderGoodsList[0][index].id,
  535. type: 1,
  536. num: 1,
  537. shopId: this.shopId
  538. }
  539. this.$Request.get("/app/order/updateGoodsNum", data).then(res => {
  540. if (res.code == 0) {
  541. this.getOrderList()
  542. } else {
  543. this.$queue.showToast(res.msg);
  544. this.goodsList.orderGoodsList[0][index].goodsNum--
  545. }
  546. });
  547. },
  548. // 减少数量
  549. noAdd(item, index) {
  550. console.log(item, index)
  551. this.goodsList.orderGoodsList[0][index].goodsNum--
  552. // this.count--;
  553. let data = {
  554. orderGoodsId: this.goodsList.orderGoodsList[0][index].id,
  555. type: 2,
  556. num: 1,
  557. shopId: this.shopId
  558. }
  559. this.$Request.get("/app/order/updateGoodsNum", data).then(res => {
  560. if (res.code == 0) {
  561. this.getOrderList()
  562. }
  563. });
  564. },
  565. // 清空购物车
  566. empty() {
  567. let data = {
  568. shopId: this.shopId,
  569. }
  570. this.$Request.post("/app/order/emptyShoppingTrolley", data).then(res => {
  571. if (res.code == 0) {
  572. this.totalPrice = 0
  573. this.goodsNum = 0
  574. this.goodsList = {
  575. orderGoodsList: [
  576. []
  577. ]
  578. }
  579. this.echoSkuList = []
  580. this.echoSku = []
  581. this.getOrderList()
  582. this.popupShow = false
  583. this.getEchoOrder()
  584. }
  585. });
  586. },
  587. // 获取购物车商品列表
  588. getOrderList() {
  589. let data = {
  590. shopId: this.shopId,
  591. page: 1,
  592. limit: 1000,
  593. status: 1,
  594. // orderType: this.orderType
  595. }
  596. this.$Request.get("/app/order/selectAllOrderList", data).then(res => {
  597. console.log(res.data,'rrrrrrrrrrrrrr')
  598. if (res.code == 0 && res.data.pageUtils.list.length) {
  599. this.goodsList = res.data.pageUtils.list[0]
  600. if (this.goodsList && this.goodsList.orderGoodsList && this.goodsList.orderGoodsList[0]) {
  601. this.totalPrice = res.data.money
  602. this.goodsNum = 0
  603. this.goodsList.orderGoodsList[0].forEach(res => {
  604. res.goodsPicture = res.goodsPicture.split(',')
  605. this.goodsNum += res.goodsNum
  606. })
  607. if (!this.goodsList.orderGoodsList[0].length) {
  608. this.popupShow = false
  609. }
  610. }
  611. }
  612. uni.hideLoading()
  613. });
  614. },
  615. // 加入购物车
  616. orderSel(e) {
  617. if (!this.userId) {
  618. uni.navigateTo({
  619. url: '/pages/public/login'
  620. })
  621. return
  622. }
  623. if (this.attrList.length) {
  624. if (this.checkString == '' || !this.CheckattrValue) {
  625. this.$queue.showToast('请选择正确的商品规格');
  626. return;
  627. }
  628. }
  629. // console.log(this.goodsDet)
  630. // console.log(this.echoSku, 'echoSku')
  631. // if (this.echoSku.length) {
  632. // this.echoSkuList.forEach(res => {
  633. // if (res.skuMessage == this.skuMessage) {
  634. // this.isEchoSku = res
  635. // }
  636. // })
  637. // if (JSON.stringify(this.isEchoSku) != "{}") {
  638. // let data = {
  639. // orderGoodsId: this.isEchoSku.id,
  640. // type: 1,
  641. // num: this.value,
  642. // shopId: this.shopId,
  643. // }
  644. // this.$Request.get("/app/order/updateGoodsNum", data).then(res => {
  645. // if (res.code == 0) {
  646. // setTimeout(function() {
  647. // uni.navigateBack()
  648. // }, 1000)
  649. // } else {
  650. // this.$queue.showToast(res.msg);
  651. // }
  652. // });
  653. // return
  654. // }
  655. // }
  656. if (this.orderId) {
  657. let data = {
  658. goodsId: this.goodsDet.goodsId,
  659. skuMessage: this.skuMessage,
  660. skuId: this.skuId,
  661. num: this.value,
  662. shopId: this.shopId,
  663. orderId: this.orderId
  664. }
  665. this.$Request.post("/app/order/joinOrder", data).then(res => {
  666. if (res.code == 0) {
  667. // this.$queue.showToast('添加成功');
  668. // if (e == 1) {
  669. // uni.navigateTo({
  670. // url: '/pages/diancan/confirmOrder?shopId=' + this.shopId
  671. // })
  672. // } else {
  673. // this.skuShow = false
  674. // this.getOrderList()
  675. // }
  676. this.$queue.showToast('添加成功');
  677. this.skuShow = false
  678. this.getOrderList()
  679. } else {
  680. this.$queue.showToast(res.msg);
  681. }
  682. })
  683. } else {
  684. let data = {
  685. goodsId: this.goodsDet.goodsId,
  686. skuMessage: this.skuMessage,
  687. skuId: this.skuId,
  688. num: this.value,
  689. shopId: this.shopId,
  690. }
  691. this.$Request.post("/app/order/insertOrder", data).then(res => {
  692. if (res.code == 0) {
  693. this.$queue.showToast('添加成功');
  694. if (e == 1) {
  695. uni.navigateTo({
  696. url: '/pages/diancan/payOrder?shopId=' + this.shopId
  697. })
  698. } else {
  699. if(this.backType!=''){
  700. setTimeout(function() {
  701. uni.navigateBack()
  702. }, 1000)
  703. }else{
  704. this.skuShow = false
  705. this.getOrderList()
  706. }
  707. }
  708. } else {
  709. this.$queue.showToast(res.msg);
  710. }
  711. })
  712. }
  713. },
  714. // 选择规格
  715. skuSel(item, index, ind) {
  716. this.attrList[index].goodsId = index
  717. this.attrList[index].attrId = ind
  718. this.checkStateList[index].name = item.name;
  719. this.checkString = '';
  720. this.checkStateList.forEach(d => {
  721. if (d.name) {
  722. if (this.checkString) {
  723. this.checkString = this.checkString + ',' + d.name;
  724. } else {
  725. this.checkString = d.name;
  726. }
  727. }
  728. });
  729. console.log(this.attrList)
  730. for (var i = 0; i < this.skuList.length; i++) {
  731. let d = this.skuList[i];
  732. if (d.detailJson == this.checkString) {
  733. console.log(d.detailJson, this.checkString)
  734. // if (d.stock > 0) {
  735. this.skuId = d.id
  736. this.skuMessage = d.detailJson
  737. this.price = d.skuPrice
  738. this.CheckattrValue = true;
  739. // } else {
  740. // this.$queue.showToast('库存不足请选择其他规格')
  741. // }
  742. break
  743. } else {
  744. this.CheckattrValue = false;
  745. }
  746. }
  747. },
  748. // 获取商品详情
  749. getData() {
  750. this.$Request.get("/app/goods/selectGoodsById?goodsId=" + this.goodsId).then(res => {
  751. uni.hideLoading()
  752. if (res.code == 0) {
  753. this.goodsDet = res.data
  754. this.goodsDet.goodsLabel = this.goodsDet.goodsLabel ? this.goodsDet.goodsLabel.split(',') :
  755. []
  756. this.goodsDet.goodsPicture = this.goodsDet.goodsPicture ? this.goodsDet.goodsPicture.split(
  757. ',') : []
  758. this.goodsDet.goodsParticularsPicture = this.goodsDet.goodsParticularsPicture ? this
  759. .goodsDet.goodsParticularsPicture.split(',') : []
  760. this.price = this.goodsDet.goodsMoney
  761. this.skuList = this.goodsDet.sku
  762. if (this.goodsDet.attr.length) {
  763. this.attrList = this.goodsDet.attr[0] ? this.goodsDet.attr[0].attrValue : []
  764. } else {
  765. this.skuId = this.goodsDet.sku[0].id
  766. }
  767. this.attrList.forEach(res => {
  768. let data = {
  769. name: ''
  770. }
  771. this.checkStateList.push(data);
  772. let detail = [];
  773. res.detail.split(',').forEach(d => {
  774. let data = {
  775. name: '',
  776. state: ''
  777. }
  778. data.name = d;
  779. detail.push(data);
  780. });
  781. res.detail = detail;
  782. })
  783. }
  784. });
  785. }
  786. }
  787. }
  788. </script>
  789. <style scoped lang="scss">
  790. .pages {
  791. width: 100%;
  792. height: 100vh;
  793. background-color: #F5F5F5;
  794. }
  795. .timess{
  796. color: #999999;
  797. font-size: 24rpx;
  798. margin-left: 10rpx;
  799. }
  800. .pinglunImg{
  801. width: 100%;
  802. margin-top: 10rpx;
  803. }
  804. .pinglunImg-box{
  805. width: 100%;
  806. image{
  807. // margin-left: 10rpx;
  808. width: 140upx;
  809. height: 140upx;
  810. border-radius: 10rpx;
  811. }
  812. }
  813. // 评价
  814. .pingjia{
  815. width: 100%;
  816. height: auto;
  817. display: flex;
  818. justify-content: center;
  819. margin-top: 20rpx;
  820. // padding-bottom: 50rpx;
  821. .pingjia-box{
  822. width: 686rpx;
  823. height: auto;
  824. background-color: #FFFFFF;
  825. border-radius: 16rpx;
  826. display: flex;
  827. justify-content: center;
  828. flex-wrap: wrap;
  829. .pingjia-box-title{
  830. // background-color: red;
  831. width: 600rpx;
  832. padding-top: 40rpx;
  833. padding-bottom: 10rpx;
  834. font-size: 32rpx;
  835. font-weight: 800;
  836. columns: #333333;
  837. }
  838. .pingjia-box-btn{
  839. width: 600rpx;
  840. display: flex;
  841. margin-top: 30rpx;
  842. padding-bottom: 50rpx;
  843. }
  844. .pingjia-box-item:nth-of-type(1){
  845. margin-top: 50rpx;
  846. }
  847. .pingjia-box-item{
  848. width: 600rpx;
  849. margin-bottom: 50rpx;
  850. }
  851. }
  852. }
  853. .skuBtn {
  854. padding: 10rpx 30rpx;
  855. border-radius: 10rpx;
  856. text-align: center;
  857. margin: 10rpx 20rpx;
  858. font-size: 28rpx;
  859. color: #333333;
  860. border: 2px solid #F2F2F2;
  861. }
  862. .info {
  863. width: 100%;
  864. height: 283rpx;
  865. display: flex;
  866. justify-content: center;
  867. margin-top: 30rpx;
  868. .info-box {
  869. width: 686rpx;
  870. height: 100%;
  871. background-color: #FFFFFF;
  872. border-radius: 16rpx;
  873. display: flex;
  874. justify-content: center;
  875. }
  876. .info-box-con {
  877. width: 615rpx;
  878. height: 100%;
  879. .info-box-con-name {
  880. width: 100%;
  881. margin-top: 30rpx;
  882. color: #333333;
  883. font-size: 38rpx;
  884. font-weight: 800;
  885. }
  886. .info-box-con-cart {
  887. width: 100%;
  888. height: 38rpx;
  889. display: flex;
  890. margin-top: 20rpx;
  891. view:nth-of-type(1) {
  892. margin-left: 0;
  893. }
  894. view {
  895. height: 100%;
  896. background: rgba(252, 210, 2, 0.2);
  897. border-radius: 4rpx;
  898. color: #FCB202;
  899. margin-left: 10rpx;
  900. padding: 0 15rpx 0 15rpx;
  901. font-size: 20rpx;
  902. font-weight: bold;
  903. display: flex;
  904. justify-content: center;
  905. align-items: center;
  906. }
  907. }
  908. .info-box-con-num {
  909. font-size: 28rpx;
  910. font-weight: 500;
  911. color: #999999;
  912. margin-top: 20rpx;
  913. }
  914. .info-box-con-select {
  915. width: 100%;
  916. height: 56rpx;
  917. display: flex;
  918. justify-content: space-between;
  919. .info-box-con-select-l {
  920. display: flex;
  921. align-items: center;
  922. view:nth-of-type(1) {
  923. color: #FF3D33;
  924. font-weight: bold;
  925. span {
  926. font-size: 24rpx;
  927. }
  928. text {
  929. font-size: 38rpx;
  930. }
  931. }
  932. view:nth-of-type(2) {
  933. color: #999999;
  934. font-weight: 500;
  935. font-size: 24rpx;
  936. margin-left: 20rpx;
  937. text {
  938. margin-left: 10rpx;
  939. }
  940. }
  941. }
  942. .info-box-con-select-r {
  943. width: 176rpx;
  944. height: 100%;
  945. display: flex;
  946. justify-content: center;
  947. align-items: center;
  948. font-size: 28rpx;
  949. color: #333333;
  950. font-weight: bold;
  951. background: #FCD202;
  952. border: 2rpx solid #FCD202;
  953. border-radius: 8rpx;
  954. }
  955. }
  956. }
  957. }
  958. .tabs {
  959. width: 100%;
  960. display: flex;
  961. justify-content: center;
  962. margin-top: 44rpx;
  963. .tabs-box {
  964. width: 686rpx;
  965. height: 100%;
  966. display: flex;
  967. .tabs-box-item:nth-of-type(1){
  968. margin-left: 0;
  969. }
  970. .tabs-box-item {
  971. font-size: 32rpx;
  972. font-weight: bold;
  973. color: #333333;
  974. margin-left: 100rpx;
  975. width: 65rpx;
  976. display: flex;
  977. flex-wrap: wrap;
  978. justify-content: center;
  979. view{
  980. width: 55rpx;
  981. height: 10rpx;
  982. background-color: #FCD202;
  983. margin-top: 9rpx;
  984. border-radius: 10rpx;
  985. }
  986. }
  987. }
  988. }
  989. .goodsInfo{
  990. width: 100%;
  991. height: auto;
  992. display: flex;
  993. justify-content: center;
  994. margin-top: 20rpx;
  995. .goodsInfo-box{
  996. width: 686rpx;
  997. height: 100%;
  998. background: #FFFFFF;
  999. border-radius: 16rpx 16rpx 0 0;
  1000. display: flex;
  1001. justify-content: center;
  1002. .goodsInfo-box-c{
  1003. width: 600rpx;
  1004. height: 100%;
  1005. padding:40rpx 0 40rpx 0;
  1006. }
  1007. .goodsInfo-box-title{
  1008. // margin-top: 40rpx;
  1009. color: #333333;
  1010. font-size: 32rpx;
  1011. font-weight: 800;
  1012. }
  1013. .goodsInfo-box-c-item{
  1014. margin-top: 40rpx;
  1015. display: flex;
  1016. view:nth-of-type(1){
  1017. font-size: 28rpx;
  1018. color: #999999;
  1019. font-weight: 500;
  1020. }
  1021. view:nth-of-type(2){
  1022. font-size: 28rpx;
  1023. color: #333333;
  1024. font-weight: 500;
  1025. margin-left: 83rpx;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. .imgInfo{
  1031. width: 100%;
  1032. height: auto;
  1033. display: flex;
  1034. justify-content: center;
  1035. .imgInfo-box{
  1036. width: 686rpx;
  1037. background-color: #FFFFFF;
  1038. border-radius: 0 0 16rpx 16rpx;
  1039. .imgInfo-box-title{
  1040. width: 100%;
  1041. text-align: center;
  1042. font-size: 28rpx;
  1043. font-weight: bold;
  1044. }
  1045. .imgInfo-box-img{
  1046. margin-top: 20rpx;
  1047. image{
  1048. width: 100%;
  1049. margin-top: -6rpx;
  1050. }
  1051. }
  1052. }
  1053. }
  1054. .settlement {
  1055. width: 94%;
  1056. background-color: #000000;
  1057. line-height: 3.4;
  1058. border-radius: 49rpx;
  1059. position: fixed;
  1060. bottom: 10rpx;
  1061. left: 3%;
  1062. display: flex;
  1063. justify-content: space-between;
  1064. }
  1065. .settlement1 {
  1066. width: 94%;
  1067. background-color: #000000;
  1068. line-height: 2.8;
  1069. border-radius: 49rpx;
  1070. position: relative;
  1071. /* bottom: 10rpx; */
  1072. left: 0;
  1073. right: 0;
  1074. /* left: 3%; */
  1075. display: flex;
  1076. justify-content: space-between;
  1077. margin: 20rpx auto;
  1078. }
  1079. .settlement_le {
  1080. width: 45%;
  1081. padding-left: 20%;
  1082. color: #FFFFFF;
  1083. font-size: 30rpx;
  1084. }
  1085. .settlement_le text {
  1086. font-size: 22rpx;
  1087. }
  1088. .settlement_ri {
  1089. width: 35%;
  1090. background-color: #FCD202;
  1091. font-family: PingFang SC;
  1092. font-weight: 800;
  1093. color: #333333;
  1094. display: flex;
  1095. justify-content: center;
  1096. align-items: center;
  1097. border-top-right-radius: 49rpx;
  1098. border-bottom-right-radius: 49rpx;
  1099. }
  1100. .settlement_img {
  1101. width: 91rpx;
  1102. height: 96rpx;
  1103. position: absolute;
  1104. // bottom: 30rpx;
  1105. left: 5%;
  1106. }
  1107. .settlement_img image {
  1108. width: 74rpx;
  1109. height: 81rpx;
  1110. }
  1111. .settlement_hot {
  1112. width: 35rpx;
  1113. height: 35rpx;
  1114. line-height: 35rpx;
  1115. text-align: center;
  1116. border-radius: 50%;
  1117. position: absolute;
  1118. top: -10rpx;
  1119. right: 0;
  1120. background-color: #FF130A;
  1121. color: #FFFFFF;
  1122. font-size: 20rpx;
  1123. font-weight: bold;
  1124. color: #FFFFFF;
  1125. }
  1126. .select_all {
  1127. width: 100%;
  1128. position: relative;
  1129. }
  1130. .btn {
  1131. padding: 10rpx 30rpx;
  1132. /* height: 60rpx; */
  1133. /* background-color: #F2F2F2; */
  1134. border-radius: 10rpx;
  1135. text-align: center;
  1136. /* line-height: 60rpx; */
  1137. margin-right: 20rpx;
  1138. font-size: 28rpx;
  1139. color: #333333;
  1140. border: 2px solid #F2F2F2;
  1141. }
  1142. .active {
  1143. /* border: 2px solid #FCD202 !important;
  1144. background: #FCD202 !important; */
  1145. background: rgba(252, 210, 2, 0.2) !important;
  1146. border: 2px solid #FCD202 !important;
  1147. opacity: 0.6;
  1148. }
  1149. .detail_all {
  1150. position: relative;
  1151. }
  1152. /* banner */
  1153. .detail-banner {
  1154. width: 100%;
  1155. height: 400rpx;
  1156. }
  1157. .detail-banner image {
  1158. width: 100%;
  1159. height: 400rpx;
  1160. }
  1161. /* 详情 */
  1162. .detail {
  1163. width: 100%;
  1164. padding: 3%;
  1165. overflow: hidden;
  1166. position: relative;
  1167. top: -20rpx;
  1168. background-color: #FFFFFF;
  1169. border-radius: 32rpx 0 0 0;
  1170. }
  1171. .detail_text {
  1172. font-size: 36rpx;
  1173. font-weight: 800;
  1174. color: #333333;
  1175. }
  1176. .detail_biao {
  1177. display: flex;
  1178. padding: 2% 0;
  1179. }
  1180. .detail_biao_sty {
  1181. /* padding: 1% 1.5%; */
  1182. padding: 10rpx 20rpx;
  1183. background: #FCD202;
  1184. opacity: 0.6;
  1185. color: #666666;
  1186. border-radius: 8rpx;
  1187. font-size: 24rpx;
  1188. margin-right: 2%;
  1189. }
  1190. .detail_text2 {
  1191. font-size: 24rpx;
  1192. font-family: PingFang SC;
  1193. color: #333333;
  1194. margin-top: 1%;
  1195. }
  1196. .detail_biao2 {
  1197. display: flex;
  1198. padding: 1% 0;
  1199. font-size: 30rpx;
  1200. }
  1201. .detail_biao2_sty {
  1202. padding: 1% 2.5%;
  1203. /* width: 13%; */
  1204. text-align: center;
  1205. background: rgba(252, 210, 2, 0.2);
  1206. border: 2rpx solid #FCD202;
  1207. opacity: 0.6;
  1208. border-radius: 8rpx;
  1209. margin-right: 2%;
  1210. }
  1211. .detail_biao2_sty2 {
  1212. padding: 1% 2.5%;
  1213. /* width: 13%; */
  1214. text-align: center;
  1215. border: 2rpx solid #999999;
  1216. opacity: 0.6;
  1217. color: #999999;
  1218. border-radius: 8rpx;
  1219. margin-right: 3%;
  1220. }
  1221. /* 产品描述 */
  1222. .detail_describe {
  1223. width: 100%;
  1224. padding: 3% 0;
  1225. /* margin-bottom: 180rpx; */
  1226. position: relative;
  1227. // top: -40rpx;
  1228. top: 30rpx;
  1229. }
  1230. .detail_describe_ce {
  1231. width: 100%;
  1232. background-color: #FFFFFF;
  1233. padding: 3%;
  1234. font-size: 24rpx;
  1235. padding-bottom: 100upx;
  1236. }
  1237. .detail_describe_text {
  1238. font-size: 30rpx;
  1239. font-weight: 500;
  1240. color: #333333;
  1241. margin-bottom: 20rpx;
  1242. }
  1243. .detail_describe_text2 {
  1244. font-weight: 500;
  1245. margin-top: 2%;
  1246. color: #999999;
  1247. }
  1248. /* 加购 */
  1249. .detail_account {
  1250. width: 100%;
  1251. background-color: #FFFFFF;
  1252. padding: 3%;
  1253. margin-top: 2%;
  1254. position: fixed;
  1255. bottom: 0;
  1256. box-shadow: 0 -10rpx 20rpx #CCCCCC;
  1257. }
  1258. .detail_account_text {
  1259. font-size: 35rpx;
  1260. font-weight: bold;
  1261. color: #333333;
  1262. }
  1263. .detail_account_text text {
  1264. font-size: 27rpx;
  1265. }
  1266. .detail_account_top {
  1267. width: 100%;
  1268. display: flex;
  1269. justify-content: space-between;
  1270. align-items: center;
  1271. }
  1272. .detail_account_top_le {
  1273. width: 80%;
  1274. padding-bottom: 32upx;
  1275. padding-top: 32upx;
  1276. }
  1277. .detail_account_top_ri {
  1278. width: 20%;
  1279. display: flex;
  1280. margin-top: 2%;
  1281. }
  1282. .detail_account_top_text {
  1283. padding: 2%;
  1284. line-height: 54rpx;
  1285. }
  1286. .detail_account_top_ri image {
  1287. width: 54rpx;
  1288. height: 54rpx;
  1289. }
  1290. .detail_account_bottom {
  1291. margin-top: 20rpx;
  1292. width: 100%;
  1293. display: flex;
  1294. justify-content: space-between;
  1295. /* margin: 4% 0 3%; */
  1296. }
  1297. .detail_account_bottom_le {
  1298. width: 47.5%;
  1299. /* margin-right: 5%; */
  1300. border-radius: 44rpx;
  1301. text-align: center;
  1302. line-height: 2.8;
  1303. border: 2rpx solid #FCD202;
  1304. }
  1305. .detail_account_bottom_ri {
  1306. width: 47.5%;
  1307. border-radius: 44rpx;
  1308. text-align: center;
  1309. line-height: 2.8;
  1310. background-color: #FCD202;
  1311. }
  1312. </style>