goodDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view>
  3. <!-- <view class="detail-banner ">
  4. <swiper class="swiper" :autoplay="true" interval="2000" duration="500" :circular="true" style="width: 100%;height: 410rpx;">
  5. <swiper-item v-for="(item,index) in dataCentre.goodsPicture" :key='index' >
  6. <image :src="item" mode="scaleToFill" style="width: 100%;"></image>
  7. </swiper-item>
  8. </swiper>
  9. </view> -->
  10. <view class="flex padding bg-white">
  11. <image :src="dataCentre.goodsCover" style="width:200rpx;height:200rpx;border-radius: 10rpx;"></image>
  12. <view class="flex flex-direction justify-between margin-left">
  13. <view class="text-black text-bold text-lg">{{dataCentre.goodsName}}</view>
  14. <view class="flex">
  15. <view v-if="dataCentre.goodsLabel1.length>0" class="btn margin-right-xs"
  16. v-for="(item,index) in dataCentre.goodsLabel1" :key='index'>{{item}}</view>
  17. </view>
  18. <view v-if="type==1">库存:{{dataCentre.inventory?dataCentre.inventory:0}}</view>
  19. <view class="text-lg text-red"><text class="text-sm">¥</text>{{dataCentre.goodsMoney}}</view>
  20. </view>
  21. </view>
  22. <!-- <view class="detail">
  23. <view class="detail_text">{{dataCentre.goodsName}}</view>
  24. <view class="detail_biao" v-if="dataCentre.goodsLabel.length">
  25. <view class="detail_biao_sty" v-for="(ite, ind) in dataCentre.goodsLabel" :key='ind'>{{ite}}</view>
  26. </view>
  27. <view class="margin-top" v-for="(item,index) in attrList" :key="index" >
  28. <view class="text-bold text-black">{{item.value}}</view>
  29. <view class="flex margin-tb-sm flex-wrap">
  30. <view v-for="(ite, ind) in item.detail" :key="ind" @click="skuSel(ite,index,ind)"
  31. class="margin-bottom-sm">
  32. <view class="btn" :class="item.goodsId == index && item.attrId == ind?'active': ''">
  33. {{ite.name}}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view> -->
  39. <view class="padding bg-white">
  40. <text class="text-bold text-black text-lg ">商品介绍</text>
  41. <u-parse class='margin-top' :html="dataCentre.goodsDescribe"></u-parse>
  42. </view>
  43. <view class="padding margin-top-sm bg-white">
  44. <view class="text-bold text-black text-lg ">其他信息</view>
  45. <view class="flex justify-between align-center margin-tb-sm">
  46. <view style="font-size:30upx;color:#999999;">商品售价</view>
  47. <view class="text-black">{{dataCentre.goodsMoney?dataCentre.goodsMoney:'暂无'}}</view>
  48. </view>
  49. <view class="flex justify-between align-center margin-tb-sm">
  50. <view style="font-size:30upx;color:#999999;">打包费</view>
  51. <view class="text-black">{{dataCentre.packMoney?dataCentre.packMoney:'0'}}</view>
  52. </view>
  53. <view class="flex justify-between align-center margin-tb-sm">
  54. <view style="font-size:30upx;color:#999999;">标签</view>
  55. <view class="text-black">{{dataCentre.goodsLabel?dataCentre.goodsLabel:'暂无'}}</view>
  56. </view>
  57. <view class="flex justify-between align-center margin-tb-sm">
  58. <view style="font-size:30upx;color:#999999;">创建时间</view>
  59. <view class="text-black">{{dataCentre.createTime}}</view>
  60. </view>
  61. </view>
  62. <view class="padding margin-top-sm bg-white" v-if="type==1">
  63. <view class="text-bold text-black text-lg ">其他设置</view>
  64. <view class="flex justify-between align-center margin-tb-sm">
  65. <view>商品状态</view>
  66. <u-switch @change="change" active-color="#FFCC00" v-model="checked"></u-switch>
  67. </view>
  68. <view class="flex justify-between align-center margin-tb-sm">
  69. <view>库存编辑</view>
  70. <input type="number" placeholder="请输入修改库存数" style="text-align: right;" v-model="inventory" />
  71. </view>
  72. </view>
  73. <!-- <view class="bg padding">
  74. <view class="flex justify-between ">
  75. <view style="font-size:40upx;"><text class="text-sm">¥</text>12.00</view>
  76. <view style="color:#999999;" class="text-sm">库存236</view>
  77. </view>
  78. <view class="text-lg text-bold padding-tb-xs">草莓沫沫酸奶奶昔</view>
  79. <view class="flex">
  80. <view class="btn">人气爆款</view>
  81. <view class="btn">福利必点系列</view>
  82. </view>
  83. <view class="text-sm padding-tb-sm">规格</view>
  84. <view class="flex">
  85. <view class="box" v-for="(item,index) in list" :key="index" @click="bindge(index)"
  86. :class="count == index?'boxs':''">{{item.name}}</view>
  87. </view>
  88. <view class="text-sm padding-tb-sm">甜度</view>
  89. <view class="flex">
  90. <view class="box" v-for="(item,index) in lists" :key="index" @click="bindtd(index)"
  91. :class="counts == index?'boxs':''">{{item.name}}</view>
  92. </view>
  93. </view>
  94. <view class="margin-top-sm padding-lr bg">
  95. <view class="text-sm padding-top-sm">规格</view>
  96. <view class="text-sm padding-tb-sm">蜂蜜黄油,辣辣海苔2款口味可选。精选优质新鲜马铃薯,使用低
  97. 温真空油炸VF技术锁鲜,香甜不腻,咖哧酥脆,净含量:50</view>
  98. </view> -->
  99. <!-- <view class="bg padding margin-top-sm">
  100. <view class="flex justify-between padding-tb-sm">
  101. <view>打包费</view>
  102. <view>¥5</view>
  103. </view>
  104. <view class="flex justify-between padding-tb-sm">
  105. <view>折扣价</view>
  106. <view>¥9.9</view>
  107. </view>
  108. </view> -->
  109. <view v-if="type==1" class="addgood" @click="save()">保存</view>
  110. <view v-if="type==2" class="addgood" @click="goAdd(dataCentre.goodsId)">修改商品</view>
  111. <view v-if="type==1" class="addgood" @click="del()">删除</view>
  112. </view>
  113. </template>
  114. <script>
  115. export default {
  116. data() {
  117. return {
  118. list: [{
  119. name: '标准'
  120. }],
  121. count: 0,
  122. lists: [{
  123. name: '无糖'
  124. }, {
  125. name: '少糖'
  126. }, {
  127. name: '半糖'
  128. }],
  129. counts: 0,
  130. goodsId: '',
  131. good: {},
  132. dataCentre: {},
  133. checked: false,
  134. shopId: '',
  135. inventory: '',
  136. type: 1,
  137. status: 1,
  138. attrList: [],
  139. skuList: [],
  140. }
  141. },
  142. onLoad(option) {
  143. uni.showLoading({
  144. title: '加载中......',
  145. mask: true, // 是否显示透明蒙层,防止触摸穿透
  146. icon: 'loading'
  147. })
  148. console.log(option)
  149. this.goodsId = option.goodsId
  150. this.shopId = uni.getStorageSync('shopId')
  151. this.type = option.type
  152. this.getGoodDet()
  153. },
  154. onShow() {
  155. this.getGoodDet()
  156. },
  157. methods: {
  158. goAdd(goodsId) {
  159. uni.navigateTo({
  160. url: '/my/publish/goods?goodsId='+goodsId
  161. })
  162. },
  163. change(e) {
  164. console.log()
  165. let that = this
  166. let data = {
  167. shopId: that.shopId,
  168. goodsId: that.goodsId,
  169. status: e ? 0 : 1
  170. }
  171. that.$Request.postA("/admin/goodsShop/soldOutOrPutaway", data).then(res => {
  172. if (res.code == 0) {
  173. // that.getGoodsList()
  174. uni.showToast({
  175. title: e ? '上架成功' : '下架成功',
  176. icon: 'none'
  177. })
  178. uni.setStorageSync('updata', true)
  179. setTimeout(function() {
  180. let pages = getCurrentPages(); // 当前页面
  181. let beforePage = pages[pages.length - 2]; // 上一页
  182. uni.navigateBack();
  183. }, 1000)
  184. }
  185. });
  186. },
  187. getGoodDet() {
  188. if (this.type == 1) {
  189. let data = {
  190. goodsId: this.goodsId,
  191. shopId: this.shopId
  192. }
  193. this.$Request.getA("/admin/goodsShop/selectGoodsByShopIdAndGoodsId", data).then(res => {
  194. if (res.code == 0) {
  195. uni.hideLoading()
  196. this.dataCentre = res.data
  197. this.attrList.forEach(res => {
  198. let data = {
  199. name: ''
  200. }
  201. // this.checkStateList.push(data);
  202. let detail = [];
  203. res.detail.split(',').forEach(d => {
  204. let data = {
  205. name: '',
  206. state: ''
  207. }
  208. data.name = d;
  209. detail.push(data);
  210. });
  211. res.detail = detail;
  212. })
  213. console.log(this.attrList)
  214. }
  215. });
  216. } else {
  217. let data = {
  218. goodsId: this.goodsId
  219. }
  220. this.$Request.getA("/admin/goods/selectGoodsById", data).then(res => {
  221. if (res.code == 0) {
  222. uni.hideLoading()
  223. this.dataCentre = res.data
  224. this.attrList.forEach(res => {
  225. let data = {
  226. name: ''
  227. }
  228. // this.checkStateList.push(data);
  229. let detail = [];
  230. res.detail.split(',').forEach(d => {
  231. let data = {
  232. name: '',
  233. state: ''
  234. }
  235. data.name = d;
  236. detail.push(data);
  237. });
  238. res.detail = detail;
  239. })
  240. console.log(this.attrList)
  241. }
  242. });
  243. }
  244. },
  245. // 修改库存
  246. save() {
  247. let data = {
  248. goodsId: this.goodsId,
  249. shopId: this.shopId,
  250. inventory: this.inventory
  251. }
  252. this.$Request.postJsonA("/admin/goodsShop/updateGoodsByShopId", data).then(res => {
  253. if (res.code == 0) {
  254. uni.showToast({
  255. title: '保存成功',
  256. icon: 'none'
  257. })
  258. uni.setStorageSync('updata', true)
  259. setTimeout(function() {
  260. uni.navigateBack({
  261. delta: 1
  262. })
  263. }, 1000)
  264. }
  265. });
  266. },
  267. // 添加
  268. add(e) {
  269. let data = [{
  270. goodsId: this.goodsId,
  271. shopId: this.shopId
  272. }]
  273. this.$Request.postJsonA("/admin/goodsShop/addGoodsByShopId", data).then(res => {
  274. if (res.code == 0) {
  275. // this.page = 1
  276. // this.getGoodsList()
  277. uni.showToast({
  278. title: '添加成功',
  279. icon: 'none'
  280. })
  281. uni.setStorageSync('updata', true)
  282. setTimeout(function() {
  283. uni.navigateBack({
  284. delta: 2
  285. })
  286. }, 1000)
  287. }
  288. });
  289. },
  290. // 删除
  291. del(e) {
  292. let that = this
  293. uni.showModal({
  294. title: '提示',
  295. content: '确认删除商品吗',
  296. success: function(res) {
  297. if (res.confirm) {
  298. console.log('用户点击确定');
  299. let data = {
  300. shopId: that.shopId,
  301. goodsId: this.goodsId,
  302. }
  303. that.$Request.postA("/admin/goodsShop/deleteGoodsByShopId", data).then(res => {
  304. if (res.code == 0) {
  305. // that.getGoodsList()
  306. uni.showToast({
  307. title: '删除成功',
  308. icon: 'none'
  309. })
  310. setTimeout(function() {
  311. let pages = getCurrentPages(); // 当前页面
  312. let beforePage = pages[pages.length - 2]; // 上一页
  313. uni.navigateBack({
  314. success: function() {
  315. beforePage
  316. .onLoad(); // 执行上一页的onLoad方法
  317. }
  318. });
  319. }, 1000)
  320. }
  321. });
  322. } else if (res.cancel) {
  323. console.log('用户点击取消');
  324. }
  325. }
  326. });
  327. },
  328. }
  329. }
  330. </script>
  331. <style>
  332. page {
  333. background: #EDF1F7;
  334. }
  335. .bg {
  336. background: #FFFFFF;
  337. }
  338. .btn {
  339. background: rgba(216, 2, 4, 0.2);
  340. opacity: 0.6;
  341. border-radius: 4upx;
  342. color: #D80204;
  343. padding: 8rpx 13rpx;
  344. font-size: 23rpx;
  345. margin-right: 16rpx;
  346. }
  347. .box {
  348. border: 2upx solid #CCCCCC;
  349. /* opacity: 0.6; */
  350. border-radius: 8upx;
  351. color: #999999;
  352. font-size: 30upx;
  353. padding: 13rpx 44rpx;
  354. margin-right: 35rpx;
  355. }
  356. .boxs {
  357. background: rgba(252, 210, 2, 0.2);
  358. border: 2upx solid #FCD202;
  359. /* opacity: 0.6; */
  360. border-radius: 8upx;
  361. color: #333333 !important;
  362. font-size: 30upx;
  363. padding: 13rpx 44rpx;
  364. }
  365. .addgood {
  366. width: 685upx;
  367. height: 88upx;
  368. background: #FFCC00;
  369. border-radius: 8upx;
  370. text-align: center;
  371. line-height: 88rpx;
  372. margin: 40rpx auto;
  373. /* position: fixed;
  374. bottom: 35rpx;
  375. left: 0;
  376. right: 0; */
  377. font-size: 32rpx;
  378. font-weight: bold;
  379. color: #FFFFFF;
  380. }
  381. .detail-banner {
  382. width: 100%;
  383. height: 410rpx;
  384. }
  385. .detail-banner image {
  386. width: 100%;
  387. height: 410rpx;
  388. }
  389. .detail {
  390. width: 100%;
  391. padding: 3%;
  392. overflow: hidden;
  393. /* position: relative; */
  394. /* top: -20rpx; */
  395. background-color: #FFFFFF;
  396. border-radius: 32rpx 0 0 0;
  397. }
  398. .detail_text {
  399. font-size: 36rpx;
  400. font-weight: 800;
  401. color: #333333;
  402. }
  403. .detail_biao {
  404. display: flex;
  405. padding: 2% 0;
  406. }
  407. .detail_biao_sty {
  408. /* padding: 1% 1.5%; */
  409. padding: 10rpx 20rpx;
  410. background: rgba(216, 2, 4, 0.2);
  411. opacity: 0.6;
  412. color: #D80204;
  413. border-radius: 8rpx;
  414. font-size: 24rpx;
  415. margin-right: 2%;
  416. }
  417. .detail_text2 {
  418. font-size: 24rpx;
  419. font-family: PingFang SC;
  420. color: #333333;
  421. margin-top: 1%;
  422. }
  423. .detail_biao2 {
  424. display: flex;
  425. padding: 1% 0;
  426. font-size: 30rpx;
  427. }
  428. .detail_biao2_sty {
  429. padding: 1% 2.5%;
  430. /* width: 13%; */
  431. text-align: center;
  432. background: rgba(252, 210, 2, 0.2);
  433. border: 2rpx solid #FCD202;
  434. opacity: 0.6;
  435. border-radius: 8rpx;
  436. margin-right: 2%;
  437. }
  438. .detail_biao2_sty2 {
  439. padding: 1% 2.5%;
  440. /* width: 13%; */
  441. text-align: center;
  442. border: 2rpx solid #999999;
  443. opacity: 0.6;
  444. color: #999999;
  445. border-radius: 8rpx;
  446. margin-right: 3%;
  447. }
  448. </style>