瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

375 lines
7.3 KiB

3 months ago
  1. <template>
  2. <view class="publishPost">
  3. <navbar
  4. leftClick
  5. @leftClick="$utils.navigateBack"
  6. title="编辑商品"/>
  7. <!-- <view class="title-input box">
  8. <input type="text" placeholder="取个吸引人的标题吧" v-model="form.title"/>
  9. </view> -->
  10. <view class="category">
  11. <view class="title">
  12. 商品图片
  13. </view>
  14. <uv-upload
  15. :fileList="fileList"
  16. :maxCount="imageMax"
  17. multiple
  18. width="150rpx"
  19. height="150rpx"
  20. name="fileList"
  21. @delete="deleteImage"
  22. @afterRead="afterRead"
  23. :previewFullImage="true"></uv-upload>
  24. </view>
  25. <view class="category">
  26. <view class="title">
  27. 选择分类
  28. </view>
  29. <view class="tagList">
  30. <view
  31. :class="{act : t.value == form.className}"
  32. @click="clickCategory(t, i)"
  33. v-for="(t, i) in productCategory"
  34. :key="i">
  35. {{ t.name }}
  36. </view>
  37. </view>
  38. </view>
  39. <view class="title-input box">
  40. <view class="shop-box">
  41. 标题
  42. </view>
  43. <input type="text" placeholder="请输入标题" v-model="form.name"/>
  44. </view>
  45. <view class="title-input box">
  46. <view class="shop-box">
  47. 副标题
  48. </view>
  49. <input type="text" placeholder="请输入商品副标题" v-model="form.nameSub"/>
  50. </view>
  51. <view class="title-input box">
  52. <view class="shop-box">
  53. 价格
  54. </view>
  55. <input type="number" placeholder="请输入商品价格" v-model="form.price"/>
  56. </view>
  57. <view class="title-input box">
  58. <view class="shop-box">
  59. 原价
  60. </view>
  61. <input type="number" placeholder="请输入商品原价" v-model="form.oldPrice"/>
  62. </view>
  63. <view class="title-input box">
  64. <view class="shop-box">
  65. 积分
  66. </view>
  67. <input type="number" placeholder="请输入积分" v-model="form.points"/>
  68. </view>
  69. <view class="category">
  70. <view class="title">
  71. 商品详情图片
  72. </view>
  73. <view class="images box">
  74. <uv-upload
  75. :fileList="imageDetailsList"
  76. :maxCount="imageMax"
  77. multiple
  78. width="150rpx"
  79. height="150rpx"
  80. name="imageDetailsList"
  81. @delete="deleteImage"
  82. @afterRead="afterRead"
  83. :previewFullImage="true"></uv-upload>
  84. </view>
  85. </view>
  86. <!-- <view class="category">
  87. <view class="title">
  88. 选择地区
  89. </view>
  90. <view class="tagList">
  91. <view
  92. :class="{act : t.name == form.address}"
  93. @click="clickAddress(t, i)"
  94. v-for="(t, i) in cityList"
  95. :key="i">
  96. {{ t.name }}
  97. </view>
  98. </view>
  99. </view> -->
  100. <!-- <view class="configBtn"
  101. @click="$refs.configPopup.open()">
  102. 发布须知
  103. </view> -->
  104. <view class="uni-color-btn"
  105. @click="submit">
  106. 发布
  107. </view>
  108. <configPopup
  109. ref="configPopup"
  110. :text="headInfo.save_no && headInfo.save_no.keyDetails"
  111. />
  112. </view>
  113. </template>
  114. <script>
  115. import { mapState } from 'vuex'
  116. import productMixins from '@/mixins/product.js'
  117. export default {
  118. components : {
  119. },
  120. mixins : [productMixins],
  121. data() {
  122. return {
  123. form : {
  124. name : '',
  125. nameSub : '',
  126. price : '',
  127. num : '',
  128. oldPrice : '',
  129. className : 0,
  130. points : '',
  131. isOpen : 'Y',
  132. shopId : '',
  133. },
  134. id : 0,
  135. fileList : [],
  136. imageDetailsList : [],
  137. codeFileList : [],
  138. imageMax : 9,
  139. };
  140. },
  141. computed : {
  142. ...mapState([]),
  143. },
  144. onLoad(args) {
  145. this.id = args.id
  146. this.form.shopId = args.shopId
  147. // this.form.address = this.cityList[0].name
  148. this.imageMax = args.imageMax || 9
  149. this.getDateil()
  150. },
  151. onShow() {
  152. },
  153. methods : {
  154. clickCategory(item, index){
  155. this.form.className = item.value
  156. },
  157. getDateil(){
  158. if(!this.id){
  159. return
  160. }
  161. let self = this
  162. this.$api('getShopPingDetail', {
  163. id : this.id
  164. }, res => {
  165. if (res.code == 200) {
  166. self.form.id = res.result.id
  167. self.form.name = res.result.name
  168. self.form.nameSub = res.result.nameSub
  169. self.form.points = res.result.points
  170. self.form.price = res.result.price
  171. self.form.oldPrice = res.result.oldPrice
  172. self.form.className = res.result.className || self.form.className
  173. if(res.result.image){
  174. res.result.image.split(',')
  175. .forEach(url => {
  176. self.fileList.push({
  177. url
  178. })
  179. })
  180. }
  181. if(res.result.imageDetails){
  182. res.result.imageDetails.split(',')
  183. .forEach(url => {
  184. self.imageDetailsList.push({
  185. url
  186. })
  187. })
  188. }
  189. }
  190. })
  191. },
  192. deleteImage(e){
  193. this[e.name].splice(e.index, 1)
  194. },
  195. afterRead(e){
  196. let self = this
  197. e.file.forEach(file => {
  198. self.$Oss.ossUpload(file.url).then(url => {
  199. self[e.name].push({
  200. url
  201. })
  202. })
  203. })
  204. },
  205. // 提交
  206. submit(){
  207. this.form.image = this.fileList.map((item) => item.url).join(",")
  208. this.form.imageDetails = this.imageDetailsList.map((item) => item.url).join(",")
  209. if (this.$utils.verificationAll(this.form, {
  210. image : '请上传商品图片',
  211. name: '请输入商品标题',
  212. nameSub: '请输入商品副标题',
  213. price: '请输入商品价格',
  214. oldPrice: '请输入商品原价',
  215. points: '请输入积分',
  216. imageDetails : '请上传商品详情图片',
  217. })) {
  218. return
  219. }
  220. delete this.form.shop
  221. this.$api('orderSaveOrUpdate', this.form, res => {
  222. if(res.code == 200){
  223. uni.showToast({
  224. title: '保存成功!',
  225. icon: 'none'
  226. })
  227. setTimeout(uni.navigateBack, 1000, -1)
  228. }
  229. })
  230. },
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .publishPost{
  236. background-color: #fff;
  237. min-height: 100vh;
  238. font-size: 28rpx;
  239. padding-bottom: 150rpx;
  240. /deep/ .uv-textarea{
  241. background-color: transparent;
  242. border: none;
  243. }
  244. /deep/ .uv-textarea__count{
  245. background-color: transparent !important;
  246. }
  247. .box{
  248. padding: 0 20rpx;
  249. }
  250. .images{
  251. display: flex;
  252. flex-wrap: wrap;
  253. padding: 20rpx;
  254. }
  255. .title-input{
  256. margin: 10rpx;
  257. border-bottom: 1px solid #00000015;
  258. padding-bottom: 25rpx;
  259. margin-bottom: 15rpx;
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. input{
  264. width: 100%;
  265. }
  266. .shop-box{
  267. font-size: 28rpx;
  268. flex-shrink: 0;
  269. font-weight: 900;
  270. width: 140rpx;
  271. }
  272. }
  273. .content-input{
  274. min-height: 400rpx;
  275. /deep/ .uv-textarea{
  276. min-height: 400rpx;
  277. }
  278. }
  279. .upTop{
  280. .title{
  281. padding-top: 20rpx;
  282. padding-left: 20rpx;
  283. border-top: 1px solid #00000015;
  284. display: flex;
  285. align-items: center;
  286. }
  287. .list{
  288. padding-top: 30rpx;
  289. width: 100%;
  290. .item{
  291. display: flex;
  292. padding: 20rpx;
  293. padding-left: 80rpx;
  294. justify-content: space-between;
  295. width: 600rpx;
  296. border-bottom: 1px solid #00000015;
  297. align-items: center;
  298. }
  299. }
  300. }
  301. .configBtn{
  302. padding: 20rpx;
  303. color: #777;
  304. padding-top: 40rpx;
  305. font-size: 28rpx;
  306. }
  307. .confirmationPopup{
  308. display: flex;
  309. flex-direction: column;
  310. align-items: center;
  311. justify-content: center;
  312. width: 100%;
  313. height: 300rpx;
  314. image{
  315. margin-top: 40rpx;
  316. }
  317. .info{
  318. margin-top: 40rpx;
  319. font-size: 26rpx;
  320. }
  321. }
  322. }
  323. .category{
  324. padding: 20rpx;
  325. .title{
  326. font-weight: 900;
  327. // font-size: 30rpx;
  328. padding-bottom: 20rpx;
  329. }
  330. .tagList{
  331. display: flex;
  332. flex-wrap: wrap;
  333. padding: 10rpx 0;
  334. view{
  335. background: rgba($uni-color, 0.1);
  336. padding: 10rpx 20rpx;
  337. margin: 10rpx;
  338. border-radius: 10rpx;
  339. font-size: 26rpx;
  340. }
  341. .act{
  342. color: #fff;
  343. background: $uni-color;
  344. }
  345. }
  346. }
  347. </style>