goodDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. icon: 'loading'
  146. })
  147. console.log(option)
  148. this.goodsId = option.goodsId
  149. this.shopId = uni.getStorageSync('shopId')
  150. this.type = option.type
  151. this.getGoodDet()
  152. },
  153. onShow() {
  154. this.getGoodDet()
  155. },
  156. methods: {
  157. goAdd(goodsId) {
  158. uni.navigateTo({
  159. url: '/my/publish/goods?goodsId='+goodsId
  160. })
  161. },
  162. change(e) {
  163. console.log()
  164. let that = this
  165. let data = {
  166. shopId: that.shopId,
  167. goodsId: that.goodsId,
  168. status: e ? 0 : 1
  169. }
  170. that.$Request.postA("/admin/goodsShop/soldOutOrPutaway", data).then(res => {
  171. if (res.code == 0) {
  172. // that.getGoodsList()
  173. uni.showToast({
  174. title: e ? '上架成功' : '下架成功',
  175. icon: 'none'
  176. })
  177. uni.setStorageSync('updata', true)
  178. setTimeout(function() {
  179. let pages = getCurrentPages(); // 当前页面
  180. let beforePage = pages[pages.length - 2]; // 上一页
  181. uni.navigateBack();
  182. }, 1000)
  183. }
  184. });
  185. },
  186. getGoodDet() {
  187. if (this.type == 1) {
  188. let data = {
  189. goodsId: this.goodsId,
  190. shopId: this.shopId
  191. }
  192. this.$Request.getA("/admin/goodsShop/selectGoodsByShopIdAndGoodsId", data).then(res => {
  193. if (res.code == 0) {
  194. uni.hideLoading()
  195. this.dataCentre = res.data
  196. this.attrList.forEach(res => {
  197. let data = {
  198. name: ''
  199. }
  200. // this.checkStateList.push(data);
  201. let detail = [];
  202. res.detail.split(',').forEach(d => {
  203. let data = {
  204. name: '',
  205. state: ''
  206. }
  207. data.name = d;
  208. detail.push(data);
  209. });
  210. res.detail = detail;
  211. })
  212. console.log(this.attrList)
  213. }
  214. });
  215. } else {
  216. let data = {
  217. goodsId: this.goodsId
  218. }
  219. this.$Request.getA("/admin/goods/selectGoodsById", data).then(res => {
  220. if (res.code == 0) {
  221. uni.hideLoading()
  222. this.dataCentre = res.data
  223. this.attrList.forEach(res => {
  224. let data = {
  225. name: ''
  226. }
  227. // this.checkStateList.push(data);
  228. let detail = [];
  229. res.detail.split(',').forEach(d => {
  230. let data = {
  231. name: '',
  232. state: ''
  233. }
  234. data.name = d;
  235. detail.push(data);
  236. });
  237. res.detail = detail;
  238. })
  239. console.log(this.attrList)
  240. }
  241. });
  242. }
  243. },
  244. // 修改库存
  245. save() {
  246. let data = {
  247. goodsId: this.goodsId,
  248. shopId: this.shopId,
  249. inventory: this.inventory
  250. }
  251. this.$Request.postJsonA("/admin/goodsShop/updateGoodsByShopId", data).then(res => {
  252. if (res.code == 0) {
  253. uni.showToast({
  254. title: '保存成功',
  255. icon: 'none'
  256. })
  257. uni.setStorageSync('updata', true)
  258. setTimeout(function() {
  259. uni.navigateBack({
  260. delta: 1
  261. })
  262. }, 1000)
  263. }
  264. });
  265. },
  266. // 添加
  267. add(e) {
  268. let data = [{
  269. goodsId: this.goodsId,
  270. shopId: this.shopId
  271. }]
  272. this.$Request.postJsonA("/admin/goodsShop/addGoodsByShopId", data).then(res => {
  273. if (res.code == 0) {
  274. // this.page = 1
  275. // this.getGoodsList()
  276. uni.showToast({
  277. title: '添加成功',
  278. icon: 'none'
  279. })
  280. uni.setStorageSync('updata', true)
  281. setTimeout(function() {
  282. uni.navigateBack({
  283. delta: 2
  284. })
  285. }, 1000)
  286. }
  287. });
  288. },
  289. // 删除
  290. del(e) {
  291. let that = this
  292. uni.showModal({
  293. title: '提示',
  294. content: '确认删除商品吗',
  295. success: function(res) {
  296. if (res.confirm) {
  297. console.log('用户点击确定');
  298. let data = {
  299. shopId: that.shopId,
  300. goodsId: this.goodsId,
  301. }
  302. that.$Request.postA("/admin/goodsShop/deleteGoodsByShopId", data).then(res => {
  303. if (res.code == 0) {
  304. // that.getGoodsList()
  305. uni.showToast({
  306. title: '删除成功',
  307. icon: 'none'
  308. })
  309. setTimeout(function() {
  310. let pages = getCurrentPages(); // 当前页面
  311. let beforePage = pages[pages.length - 2]; // 上一页
  312. uni.navigateBack({
  313. success: function() {
  314. beforePage
  315. .onLoad(); // 执行上一页的onLoad方法
  316. }
  317. });
  318. }, 1000)
  319. }
  320. });
  321. } else if (res.cancel) {
  322. console.log('用户点击取消');
  323. }
  324. }
  325. });
  326. },
  327. }
  328. }
  329. </script>
  330. <style>
  331. page {
  332. background: #EDF1F7;
  333. }
  334. .bg {
  335. background: #FFFFFF;
  336. }
  337. .btn {
  338. background: rgba(216, 2, 4, 0.2);
  339. opacity: 0.6;
  340. border-radius: 4upx;
  341. color: #D80204;
  342. padding: 8rpx 13rpx;
  343. font-size: 23rpx;
  344. margin-right: 16rpx;
  345. }
  346. .box {
  347. border: 2upx solid #CCCCCC;
  348. /* opacity: 0.6; */
  349. border-radius: 8upx;
  350. color: #999999;
  351. font-size: 30upx;
  352. padding: 13rpx 44rpx;
  353. margin-right: 35rpx;
  354. }
  355. .boxs {
  356. background: rgba(252, 210, 2, 0.2);
  357. border: 2upx solid #FCD202;
  358. /* opacity: 0.6; */
  359. border-radius: 8upx;
  360. color: #333333 !important;
  361. font-size: 30upx;
  362. padding: 13rpx 44rpx;
  363. }
  364. .addgood {
  365. width: 685upx;
  366. height: 88upx;
  367. background: #FFCC00;
  368. border-radius: 8upx;
  369. text-align: center;
  370. line-height: 88rpx;
  371. margin: 40rpx auto;
  372. /* position: fixed;
  373. bottom: 35rpx;
  374. left: 0;
  375. right: 0; */
  376. font-size: 32rpx;
  377. font-weight: bold;
  378. color: #FFFFFF;
  379. }
  380. .detail-banner {
  381. width: 100%;
  382. height: 410rpx;
  383. }
  384. .detail-banner image {
  385. width: 100%;
  386. height: 410rpx;
  387. }
  388. .detail {
  389. width: 100%;
  390. padding: 3%;
  391. overflow: hidden;
  392. /* position: relative; */
  393. /* top: -20rpx; */
  394. background-color: #FFFFFF;
  395. border-radius: 32rpx 0 0 0;
  396. }
  397. .detail_text {
  398. font-size: 36rpx;
  399. font-weight: 800;
  400. color: #333333;
  401. }
  402. .detail_biao {
  403. display: flex;
  404. padding: 2% 0;
  405. }
  406. .detail_biao_sty {
  407. /* padding: 1% 1.5%; */
  408. padding: 10rpx 20rpx;
  409. background: rgba(216, 2, 4, 0.2);
  410. opacity: 0.6;
  411. color: #D80204;
  412. border-radius: 8rpx;
  413. font-size: 24rpx;
  414. margin-right: 2%;
  415. }
  416. .detail_text2 {
  417. font-size: 24rpx;
  418. font-family: PingFang SC;
  419. color: #333333;
  420. margin-top: 1%;
  421. }
  422. .detail_biao2 {
  423. display: flex;
  424. padding: 1% 0;
  425. font-size: 30rpx;
  426. }
  427. .detail_biao2_sty {
  428. padding: 1% 2.5%;
  429. /* width: 13%; */
  430. text-align: center;
  431. background: rgba(252, 210, 2, 0.2);
  432. border: 2rpx solid #FCD202;
  433. opacity: 0.6;
  434. border-radius: 8rpx;
  435. margin-right: 2%;
  436. }
  437. .detail_biao2_sty2 {
  438. padding: 1% 2.5%;
  439. /* width: 13%; */
  440. text-align: center;
  441. border: 2rpx solid #999999;
  442. opacity: 0.6;
  443. color: #999999;
  444. border-radius: 8rpx;
  445. margin-right: 3%;
  446. }
  447. </style>