creatProduct.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298
  1. <template>
  2. <view class="creat">
  3. <view class="top"></view>
  4. <view class="head">
  5. <span class="cuIcon-back" @click="back"></span>
  6. <view class="case">
  7. {{productId?'编辑商品':'创建商品' }}
  8. </view>
  9. </view>
  10. <view class="content">
  11. <view class="form" v-show="schedule == 1">
  12. <view class="titl">
  13. 基础信息
  14. </view>
  15. <view class="item">
  16. <view class="label">
  17. 商品分类<span>*</span>
  18. </view>
  19. <view class="picker" @click="selectProductType">
  20. <span v-if="showText == ''">选择商品分类</span>
  21. <span v-else style="color: #333333;">{{ showText }}</span>
  22. <u-icon name="arrow-right"></u-icon>
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="label">
  27. 商品名称<span>*</span>
  28. </view>
  29. <view class="picker">
  30. <u-input :disabled="tabIndex==1" v-model="form.productName" placeholder="输入商品名称" />
  31. </view>
  32. </view>
  33. <view class="item">
  34. <view class="label">
  35. 商品分组
  36. <!-- <span v-if="tabIndex == '0'">*</span> -->
  37. </view>
  38. <view class="picker" @click="selectGrouping">
  39. <span v-if="form.groupingName == ''">请选择</span>
  40. <span v-else style="color: #333333;">{{ form.groupingName }}</span>
  41. <u-icon name="arrow-right"></u-icon>
  42. </view>
  43. </view>
  44. <view class="item upload">
  45. <view class="label">
  46. 商品封面图<span>*</span>
  47. </view>
  48. <view class="tips">
  49. 支持jpg、png格式
  50. </view>
  51. <view v-if="tabIndex==1">
  52. <image v-for="(val,index) in fmImageList" :key="index" :src="val.url" mode=""
  53. style="width: 140rpx;height:140rpx;border-radius: 4px; border: 1px solid #ebecee;margin-right:20rpx;margin-bottom:10rpx">
  54. </image>
  55. </view>
  56. <u-upload v-else ref="uUpload" :action="action" :file-list="fmImageList" @on-success="handleSuccess"
  57. @on-remove=" handleRemove" max-count="1" width="140rpx" height="140rpx"></u-upload>
  58. </view>
  59. <view class="item upload">
  60. <view class="label">
  61. 商品详情图<span v-if="tabIndex=='0'">*</span>
  62. </view>
  63. <view class="tips">
  64. 支持jpg、png格式,最多20张
  65. </view>
  66. <view v-if="tabIndex==1">
  67. <view v-html="form.richText"></view>
  68. </view>
  69. <u-upload v-else ref="dUpload" :action="action" :file-list="xqImage" @on-success="detailsSuccess"
  70. @on-remove="detailsRemove" max-count="20" width="140rpx" height="140rpx"></u-upload>
  71. </view>
  72. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  73. <view class="label">
  74. 原价<span>*</span>
  75. </view>
  76. <view class="picker">
  77. <u-input :disabled="tabIndex==1" v-model="form.price" placeholder="输入商品原价" />
  78. </view>
  79. <view class="unit">
  80. </view>
  81. </view>
  82. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  83. <view class="label">
  84. 实际售价<span>*</span>
  85. </view>
  86. <view class="picker">
  87. <u-input type="num" :disabled="form.isUpdatePrice==0" v-model="form.soldPrice" placeholder="输入客户实际支付价" />
  88. </view>
  89. <view class="unit">
  90. </view>
  91. </view>
  92. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  93. <view class="label">
  94. 组合套餐
  95. </view>
  96. <view class="picker set" @click="goGroup">
  97. 去设置
  98. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  99. </view>
  100. </view>
  101. <!-- 钣金喷漆 -->
  102. <view class="spray" v-if="form.categoryId == '1945013773786701826'">
  103. <view class="label" style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
  104. 商品规格
  105. <view class="change">
  106. <span @click="allSelect">
  107. <image src="/static/product/select.png" mode="" v-if="all"></image>
  108. <image src="/static/product/round.png" mode="" v-else></image>
  109. 全选
  110. </span>
  111. <span @click="reverseSelsct">
  112. <image src="/static/product/select.png" mode="" v-if="reverse"></image>
  113. <image src="/static/product/round.png" mode="" v-else></image>
  114. 反选
  115. </span>
  116. </view>
  117. </view>
  118. <view class="spray_items">
  119. <view class="spra" v-for="(item,index) in form.specItems" :key="item.craftId">
  120. <view class="square" @click="select(item)">
  121. <image src="/static/product/square_select.png" mode="" v-if="item.replaced == true"></image>
  122. <image src="/static/product/square.png" mode="" v-else></image>
  123. </view>
  124. <view class="right">
  125. <view class="name">
  126. <!-- {{item.craftId}} -->
  127. {{item.partName}} {{item.positionName}} {{item.craftName}}
  128. </view>
  129. <view class="price">
  130. <view class="option">原价<input v-model="item.price" placeholder="输入商品原价" style="height: 49rpx;" />
  131. </view>
  132. <view class="option">参考售价<input v-model="item.soldPrice" placeholder="输入商品参考售价" /></view>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. <view v-show="schedule == 2">
  140. <view class="form" style="margin-bottom: 24rpx;">
  141. <view class="titl ">
  142. 下单奖励
  143. </view>
  144. <view class="prompt">提示:金豆或积分余额不足时,将自动关闭奖励,不影响商品状态</view>
  145. <view class="item" style="border:none;margin-bottom:0">
  146. <view class="label">
  147. 金豆奖励
  148. </view>
  149. <view class="picker set">
  150. <u-switch v-model="jindouChecked" :disabled="tabIndex==1" style="margin-left:8rpx;" size="28"
  151. @change="e=>e==false?form.goldAward='':''"></u-switch>
  152. </view>
  153. </view>
  154. <view style="border:none;" v-if="jindouChecked">
  155. <view class="exchange-input">
  156. <input type="digit" v-model.number="form.goldAward"
  157. @input="e => form.goldAward = e.detail.value? e.detail.value.replace(/[^\d]/g, ''):''"
  158. placeholder="请输入金豆奖励数量" placeholder-class="input-placeholder" />
  159. <text class="exchange-all">个金豆</text>
  160. </view>
  161. </view>
  162. <view class="item" style="border:none;">
  163. <view class="label">
  164. 积分奖励
  165. </view>
  166. <view class="picker set">
  167. <u-switch v-model="jifenChecked" :disabled="tabIndex==1" style="margin-left:8rpx;" size="28"
  168. @change="e=>e==false?form.integralAward='':''"></u-switch>
  169. </view>
  170. </view>
  171. <view style="border:none;" v-if="jifenChecked">
  172. <view class="exchange-input">
  173. <input type="digit" v-model.number="form.integralAward"
  174. @input="e => form.integralAward = e.detail.value? e.detail.value.replace(/[^\d]/g, ''):''"
  175. placeholder="请输入积分奖励数量" placeholder-class="input-placeholder" />
  176. <text class="exchange-all">个积分</text>
  177. </view>
  178. </view>
  179. </view>
  180. <view class="form">
  181. <view class="titl ">
  182. 售卖/使用信息
  183. </view>
  184. <view class="item">
  185. <view class="label">
  186. 售卖时间<span>*</span>
  187. </view>
  188. <view class="picker set inp" @click="selectDate">
  189. <u-input :disabled="tabIndex==1" placeholder="去设置" v-model="showDate" @click="selectDate" />
  190. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  191. </view>
  192. </view>
  193. <view class="item">
  194. <view class="label">
  195. 库存<span>*</span>
  196. </view>
  197. <view class="picker set">
  198. <u-input type="number" v-model="form.stockQuantity" placeholder="输入库存数量" />
  199. </view>
  200. </view>
  201. <view class="item">
  202. <view class="label">
  203. 可用时间<span>*</span>
  204. </view>
  205. <view class="picker set">
  206. <view class="picker set inp" @click="setUsable">
  207. <text :style="{
  208. color: showSellDate ? '#333333' : '#c0c4cc'
  209. }">{{ showSellDate || '去设置' }}</text>
  210. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  211. </view>
  212. </view>
  213. </view>
  214. <view class="item">
  215. <view class="label">
  216. 需要预约<span>*</span>
  217. </view>
  218. <view class="picker set">
  219. <u-switch v-model="makeChecked" :disabled="tabIndex==1" style="margin-left:8rpx;" size="28"></u-switch>
  220. </view>
  221. </view>
  222. <view class="item">
  223. <view class="label">
  224. 退款规则<span>*</span>
  225. </view>
  226. <view class="picker set" @click="tabIndex==0?isRefund = true:''">
  227. <view class="" v-if="showRule" style="color: #333333;">
  228. {{ showRule }}
  229. </view>
  230. <view class="" v-else>
  231. 请选择
  232. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  233. </view>
  234. </view>
  235. </view>
  236. <view class="item upload">
  237. <view class="label">
  238. 使用说明
  239. </view>
  240. <view class="textarea">
  241. <u-input v-model="form.instructions" :disabled="tabIndex==1" type="textarea" placeholder="请输入"
  242. maxlength="500" />
  243. </view>
  244. <view class="num">
  245. <span
  246. v-if="form.instructions">{{ form.instructions.length > 0 ? form.instructions.length : '0' }}</span>/500
  247. </view>
  248. </view>
  249. </view>
  250. </view>
  251. </view>
  252. <view class="btn">
  253. <view class="next" @click="next" v-if="schedule == 1">
  254. 下一步
  255. </view>
  256. <view class="handle" v-else>
  257. <view class="back" @click="schedule -= 1">
  258. 上一步
  259. </view>
  260. <view class="submit" @click="submit">
  261. 提交审核
  262. </view>
  263. </view>
  264. </view>
  265. <!-- <rangTime ref="rangTime" :mode="mode" @onSubmit="onEndTimeChange" :title="timeTitle"/> -->
  266. <refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel" @confirm="saveFound"
  267. @close="cutRule" />
  268. <view class="popup" v-if="isSelectType">
  269. <view class="model">
  270. <view class="title">
  271. 商品品类
  272. <image src="/static/index/cut.png" mode="" @click="closePopup"></image>
  273. </view>
  274. <view class="tree">
  275. <view class="left">
  276. <view class="item" :class="currentLeft == index ? 'active' : ''" v-for="(item, index) in treeLeft"
  277. :key="item.id" @click="selectLeft(item, index)">
  278. {{ item.name }}
  279. </view>
  280. </view>
  281. <view class="left border">
  282. <view class="item" :class="currentCenter == index ? 'active' : ''" v-for="(item, index) in treeCenter"
  283. :key="item.id" @click="selectRight(item, index)">
  284. {{ item.name }}
  285. </view>
  286. </view>
  287. <view class="left">
  288. <view class="item" :class="currentRight == index ? 'active' : ''" v-for="(item, index) in treeRight"
  289. :key="item.id" @click="selectLast(item, index)">
  290. {{ item.name }}
  291. </view>
  292. </view>
  293. </view>
  294. <view class="sub">
  295. <view class="submit" @click="selectType">
  296. 确定
  297. </view>
  298. </view>
  299. </view>
  300. </view>
  301. <!-- 商品分组 -->
  302. <u-select v-model="showGroupPicker" mode="single-column" label-name="name" value-name="id" :list="groupOptions"
  303. @confirm="groupConfirm($event)" @cancel="showGroupPicker = false"></u-select>
  304. </view>
  305. </template>
  306. <script>
  307. import rangTime from '../../components/dengrq-datetime-picker/dateSelector/index.vue'
  308. import refund from '@/components/product/refund.vue'
  309. import configService from '../../common/service/config.service'
  310. import {
  311. nextTick
  312. } from "vue"
  313. export default {
  314. components: {
  315. rangTime,
  316. refund
  317. },
  318. data() {
  319. return {
  320. tabIndex: '0',
  321. mode: 1,
  322. form: {
  323. instructions: '',
  324. preBook: 0,
  325. merchantId: null
  326. // categoryId:'',
  327. // productName: '',
  328. // productImage: '',
  329. // checked: null,
  330. // num: 0,
  331. // refundLabel:null,
  332. // refundConfirm:null
  333. },
  334. fmImageList: [], //封面图回显
  335. xqImage: [], //详情图回显
  336. showRule: '', //显示退款规则文字
  337. action: configService.apiUrl + '/sys/common/upload', //图片上传地址
  338. // action: 'http://192.168.0.36:8080/jeecg-boot/sys/common/upload', //图片上传地址
  339. schedule: 1, //进度
  340. fileList: [],
  341. selectedTime: null,
  342. isSelectDate: false,
  343. isRefund: false,
  344. isSelectType: false,
  345. treeLeft: [], //一级列表
  346. treeCenter: [], //二级列表
  347. treeRight: [], //三级列表
  348. currentLeft: 0, //一级选中
  349. currentCenter: 0, //二级选中
  350. currentRight: 0, //三级选中
  351. productType: [], //选中的商品分类id
  352. selectTypeList: [], //选中的商品分类名称
  353. showText: '',
  354. showDate: '',
  355. showSellDate: '',
  356. makeChecked: false,
  357. // imageHttp: 'http://192.168.0.36:8080/jeecg-boot/', //上传图片前缀+
  358. imageHttp: configService.apiUrl + '/', //上传图片前缀+
  359. productId: '',
  360. jindouChecked: false,
  361. jifenChecked: false,
  362. selectVaule: 0, //钣金喷漆选择
  363. all: false, //是否全选
  364. reverse: false, //是否反选
  365. selectProductSunItem:[],
  366. timeTitle:'选择售卖时间',
  367. // 商品分组列表
  368. showGroupPicker: false,
  369. groupOptions: [],
  370. }
  371. },
  372. mounted() {
  373. this.getProductGroup()
  374. this.getLeftTree()
  375. this.getForm()
  376. },
  377. onLoad(options) {
  378. if (options.productId) {
  379. this.productId = options.productId
  380. }
  381. if (options.tabIndex) {
  382. this.tabIndex = options.tabIndex
  383. }
  384. },
  385. onShow() {
  386. let that = this
  387. uni.getStorage({
  388. key: 'login_user_info',
  389. success: function(res) {
  390. that.form.merchantId = res.data.merchantId
  391. }
  392. })
  393. uni.getStorage({
  394. key: 'smdate',
  395. success: (res) => {
  396. if (res.data.availableEndDate) {
  397. this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
  398. this.form.availableStartDate = res.data.availableStartDate
  399. this.form.availableEndDate = res.data.availableEndDate
  400. this.form.expirationDays = null
  401. this.form.useType = 2
  402. } else if (res.data.expirationDays) {
  403. this.form.expirationDays = res.data.expirationDays
  404. this.form.availableEndDate = null
  405. this.form.availableStartDate = null
  406. this.form.useType = 1
  407. this.$nextTick(() => {
  408. this.showSellDate = res.data.expirationDays + '天后失效'
  409. });
  410. }else if(res.data.useType == 3){
  411. this.form.useType = 3
  412. this.showSellDate = '长期有效'
  413. }
  414. }
  415. })
  416. uni.getStorage({
  417. key: 'group',
  418. success: function(res) {
  419. that.form.productGroups = res.data
  420. }
  421. })
  422. },
  423. methods: {
  424. //全选
  425. allSelect() {
  426. this.all = true
  427. this.reverse = false
  428. this.form.specItems.forEach(item => {
  429. item.replaced = true
  430. })
  431. },
  432. //反选
  433. reverseSelsct() {
  434. this.reverse = true
  435. this.all = false
  436. this.form.specItems.forEach(item => {
  437. item.replaced = !item.replaced
  438. })
  439. },
  440. //选中
  441. select(item) {
  442. item.replaced = !item.replaced
  443. // const index = this.form.specItems.findIndex(i => i.id === item.id);
  444. // if (index !== -1) {
  445. // this.form.specItems.splice(index, 1, {
  446. // ...item,
  447. // replaced: !item.replaced
  448. // });
  449. // }
  450. },
  451. // 上传封面图成功回调
  452. handleSuccess(res, index, lists) {
  453. this.form.productImage = this.imageHttp + res.message
  454. },
  455. // 移除封面图文件回调
  456. handleRemove(index, lists) {
  457. this.fmImageList = [];
  458. },
  459. //上传详情图
  460. detailsSuccess(res, index, lists) {
  461. console.log(lists)
  462. this.processImageList(lists);
  463. this.xqImage = lists
  464. },
  465. detailsRemove(index, lists) {
  466. this.xqImage = lists
  467. this.processImageList(lists);
  468. },
  469. // 处理图片列表,生成URL字符串
  470. processImageList(lists) {
  471. let temp = [];
  472. lists.forEach(item => {
  473. if (item.response && item.response.message) {
  474. temp.push(this.imageHttp + item.response.message);
  475. } else if (item.url) {
  476. // 处理已存在的图片
  477. temp.push(item.url);
  478. }
  479. });
  480. this.form.detailImages = temp.join(',');
  481. console.log('当前图片URL字符串:', this.form.detailImages);
  482. },
  483. //下一步
  484. next() {
  485. let temp = []
  486. if(this.form.specItems){
  487. this.form.specItems.forEach(item => {
  488. // item.replaced = true
  489. if(item.replaced){
  490. this.selectProductSunItem.push(item)
  491. }
  492. })
  493. // this.form.specItems = temp
  494. }
  495. //基础信息必填提示
  496. if (!this.form.categoryId) {
  497. uni.showToast({
  498. title: '请选择商品分类',
  499. icon: 'none'
  500. });
  501. return
  502. }
  503. if (!this.form.productName) {
  504. uni.showToast({
  505. title: '请输入商品名称',
  506. icon: 'none'
  507. });
  508. return
  509. }
  510. if (!this.form.productImage) {
  511. uni.showToast({
  512. title: '请上传商品封面图',
  513. icon: 'none'
  514. });
  515. return
  516. }
  517. if (this.tabIndex == '0' && !this.form.detailImages) {
  518. uni.showToast({
  519. title: '请上传商品详情图',
  520. icon: 'none'
  521. });
  522. return
  523. }
  524. if (!this.form.price && !this.form.categoryId == '1945013773786701826') {
  525. uni.showToast({
  526. title: '请输入商品原价',
  527. icon: 'none'
  528. });
  529. return
  530. }
  531. if (!this.form.soldPrice && !this.form.categoryId == '1945013773786701826') {
  532. uni.showToast({
  533. title: '请输入商品售价',
  534. icon: 'none'
  535. });
  536. return
  537. } else if (this.form.categoryId == '1945013773786701826' && this.selectProductSunItem.length ==0) {
  538. uni.showToast({
  539. title: '请选择最少一个配置',
  540. icon: 'none'
  541. });
  542. } else {
  543. this.schedule += 1
  544. }
  545. },
  546. // 跳转至组合商品页
  547. goGroup() {
  548. // if(this.tabIndex==0){
  549. uni.navigateTo({
  550. url: '/pages/product/group'
  551. })
  552. // }
  553. },
  554. //返回
  555. back() {
  556. uni.navigateTo({
  557. url: '/pages/product/index'
  558. })
  559. },
  560. // 处理 confirm 事件,接收子组件传递的时间段数据
  561. handleConfirm(time) {
  562. this.selectedTime = time; // 保存时间段数据
  563. this.isSelectDate = false
  564. },
  565. //隐藏弹窗
  566. closeSelectDate() {
  567. this.isSelectDate = false
  568. },
  569. //跳转至可用时间
  570. setUsable() {
  571. let str = this.$u.queryParams({ useType: this.form.useType })
  572. uni.navigateTo({
  573. url: `/pages/product/usable${str}`
  574. })
  575. },
  576. // 更新时间
  577. updateRangeTime() {
  578. uni.getStorage({
  579. key: 'smdate',
  580. success: (res) => {
  581. if (res.data.useType == 2) {
  582. this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
  583. this.form.availableStartDate = res.data.availableStartDate
  584. this.form.availableEndDate = res.data.availableEndDate
  585. this.form.expirationDays = null
  586. this.form.useType = 2
  587. } else if (res.data.useType == 1) {
  588. this.form.expirationDays = res.data.expirationDays
  589. this.form.availableEndDate = null
  590. this.form.availableStartDate = null
  591. this.form.useType = 1
  592. this.$nextTick(() => {
  593. this.showSellDate = res.data.expirationDays + '天后失效'
  594. });
  595. } else if (res.data.useType == 3) {
  596. this.form.useType = 3
  597. this.showSellDate = '长期有效'
  598. }
  599. }
  600. })
  601. },
  602. // 保存退款规则
  603. saveFound(rules) {
  604. this.form.refundConfirm = rules.refundConfirm.refundConfirm
  605. this.form.refundLabel = rules.refundLabel.refundLabel
  606. let value1 = []
  607. value1.push(rules.refundConfirm.name, rules.refundLabel.name)
  608. this.showRule = value1.join("·")
  609. // this.selectedRules = rules;
  610. this.isRefund = false
  611. },
  612. cutRule() {
  613. this.isRefund = false
  614. },
  615. //获取商品分类一级列表
  616. getLeftTree() {
  617. this.$http.get("/sys/category/childList?pid=" + '1889836358116098050', {}).then(res => {
  618. if (res.data.code == 0) {
  619. this.treeLeft = res.data.result
  620. if (this.treeLeft[0]) {
  621. this.getCenterTree(this.treeLeft[0].id)
  622. }
  623. }
  624. })
  625. },
  626. //获取商品分类二级列表
  627. getCenterTree(id) {
  628. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  629. if (res.data.code == 0) {
  630. this.treeCenter = res.data.result
  631. if (this.treeCenter[0]) {
  632. // this.getRightTree(this.treeCenter[0].id)
  633. }
  634. }
  635. })
  636. },
  637. //获取商品分类三级列表
  638. getRightTree(id) {
  639. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  640. if (res.data.code == 0) {
  641. this.treeRight = res.data.result
  642. }
  643. })
  644. },
  645. selectProductType() {
  646. if (this.tabIndex == '0') {
  647. this.isSelectType = true
  648. this.showText = ''
  649. this.productType = []
  650. this.selectTypeList = []
  651. this.currentLeft = null
  652. this.currentCenter = null
  653. this.currentRight = null
  654. }
  655. },
  656. selectGrouping() {
  657. if (this.tabIndex == '0') {
  658. this.showGroupPicker = true
  659. }
  660. },
  661. //选中一级
  662. selectLeft(item, index) {
  663. this.currentLeft = index
  664. this.currentCenter = null
  665. this.currentRight = null
  666. this.treeCenter = []
  667. this.treeRight = []
  668. this.productType = []
  669. this.selectTypeList = []
  670. this.productType.push(item.id)
  671. this.selectTypeList.push(item.name)
  672. this.getCenterTree(item.id)
  673. },
  674. //选中二级
  675. selectRight(item, index) {
  676. this.getRightTree(this.treeCenter[0].id)
  677. this.currentCenter = index
  678. this.currentRight = null
  679. if (this.selectTypeList.length >= 2) {
  680. this.productType.splice(1, 2)
  681. this.selectTypeList.splice(1, 2)
  682. }
  683. this.productType.push(item.id)
  684. this.selectTypeList.push(item.name)
  685. this.getRightTree(item.id)
  686. },
  687. //选中三级
  688. selectLast(item, index) {
  689. if (this.selectTypeList.length >= 3) {
  690. this.productType.splice(2, 1)
  691. this.selectTypeList.splice(2, 1)
  692. }
  693. this.productType.push(item.id)
  694. this.selectTypeList.push(item.name)
  695. this.currentRight = index
  696. },
  697. //确定分类
  698. selectType() {
  699. this.isSelectType = false
  700. this.form.categoryId = this.productType.join(',')
  701. this.showText = this.selectTypeList.join('·')
  702. },
  703. //关闭选择分类弹窗
  704. closePopup() {
  705. this.isSelectType = false
  706. },
  707. //获取商品分组列表
  708. getProductGroup() {
  709. this.$http.get("/localProductGrouping/localProductGrouping/getAppList?sourceType=1").then(res => {
  710. if (res.data.success) {
  711. this.groupOptions = res.data.result || []
  712. }
  713. })
  714. },
  715. // 确定分组
  716. groupConfirm(e) {
  717. this.form.groupingId = e[0].value
  718. this.form.groupingName = e[0].label
  719. this.showGroupPicker = false;
  720. },
  721. selectDate() {
  722. // this.isSelectDate = true
  723. this.$refs.rangTime.open()
  724. },
  725. onEndTimeChange(val) {
  726. this.form.saleStartDate = val.startDate
  727. this.form.saleEndDate = val.endDate
  728. this.showDate = val.startDate + '-' + val.endDate
  729. this.$forceUpdate(); // 强制刷新视图
  730. },
  731. //提交审核
  732. submit() {
  733. console.log(this.form)
  734. this.form.specItems = this.selectProductSunItem
  735. this.makeChecked ? this.form.preBook = 1 : this.form.preBook = 0
  736. if (!this.form.saleStartDate) {
  737. uni.showToast({
  738. title: '请设置售卖时间',
  739. icon: 'none'
  740. });
  741. return
  742. } else if (!this.form.stockQuantity) {
  743. uni.showToast({
  744. title: '请输入商品库存',
  745. icon: 'none'
  746. });
  747. return
  748. } else if (!this.form.availableEndDate && !this.form.expirationDays) {
  749. uni.showToast({
  750. title: '请选择可用时间',
  751. icon: 'none'
  752. });
  753. return
  754. // } else if (this.tabIndex != 1 && (this.form.refundConfirmName == null || this.form.refundLabelName == null)) {
  755. } else if (this.tabIndex != 1 && (this.form.refundConfirm == null || this.form.refundLabel == null)) {
  756. uni.showToast({
  757. title: '请选择退款标签',
  758. icon: 'none'
  759. });
  760. return
  761. } else {
  762. if (this.productId == '') {
  763. this.$http.post("/app/product/add", this.form).then(res => {
  764. if (res.data.code == 200) {
  765. uni.showToast({
  766. title: '添加成功',
  767. icon: 'none'
  768. });
  769. this.back()
  770. uni.removeStorage({
  771. key: 'smdate',
  772. });
  773. uni.removeStorage({
  774. key: 'group',
  775. });
  776. } else {
  777. uni.showToast({
  778. title: res.data.message,
  779. icon: 'none'
  780. });
  781. }
  782. })
  783. } else {
  784. this.form.productId = this.productId
  785. this.$http.post("/app/product/edit", this.form).then(res => {
  786. if (res.data.code == 200) {
  787. uni.showToast({
  788. title: '编辑成功',
  789. icon: 'none'
  790. });
  791. this.back()
  792. } else {
  793. uni.showToast({
  794. icon: 'none',
  795. title: res.data.message
  796. })
  797. }
  798. uni.removeStorage({
  799. key: 'smdate',
  800. });
  801. uni.removeStorage({
  802. key: 'group',
  803. });
  804. })
  805. }
  806. }
  807. },
  808. //回显数据
  809. getForm() {
  810. this.$http.get("/app/product/queryById?id=" + this.productId, {}).then(res => {
  811. if (res.data.code == 200) {
  812. this.form = res.data.result
  813. this.jifenChecked = res.data.result.integralAward ? true : false
  814. this.jindouChecked = res.data.result.goldAward ? true : false
  815. this.showText = res.data.result.productCategory
  816. this.fmImageList.push({
  817. url: res.data.result.productImage
  818. })
  819. if (res.data.result.detailImages) {
  820. let xqtemp = []
  821. xqtemp = res.data.result.detailImages.split(',')
  822. xqtemp.map(item => {
  823. this.xqImage.push({
  824. url: item
  825. })
  826. })
  827. console.log(this.xqImage)
  828. }
  829. this.showDate = res.data.result.saleStartDate.slice(0, 10) + '-' + res.data.result.saleEndDate.slice(0,
  830. 10)
  831. if (res.data.resultuseType == 2) {
  832. this.showSellDate = res.data.result.availableStartDate.slice(0, 10) + '-' + res.data.result
  833. .availableEndDate.slice(0, 10)
  834. } else if (res.data.result.useType == 1) {
  835. this.showSellDate = res.data.result.expirationDays + '天后失效'
  836. }else if(res.data.result.useType == 3){
  837. this.showSellDate = '长期有效'
  838. }
  839. res.data.result.preBook == 0 ? this.makeChecked = false : this.makeChecked = true
  840. if (res.data.result.refundLabelName && res.data.result.refundConfirmName) {
  841. this.showRule = res.data.result.refundLabelName + '·' + res.data.result.refundConfirmName
  842. }
  843. console.log(this.showRule)
  844. uni.setStorage({
  845. key: 'group',
  846. data: res.data.result.productGroups
  847. })
  848. }
  849. })
  850. }
  851. },
  852. mounted() {
  853. this.getProductGroup()
  854. this.getLeftTree()
  855. this.getForm()
  856. this.updateRangeTime()
  857. },
  858. onLoad(options) {
  859. if (options.productId) {
  860. this.productId = options.productId
  861. }
  862. if (options.tabIndex) {
  863. this.tabIndex = options.tabIndex
  864. }
  865. },
  866. onShow() {
  867. let that = this
  868. uni.getStorage({
  869. key: 'login_user_info',
  870. success: function(res) {
  871. that.form.merchantId = res.data.merchantId
  872. }
  873. })
  874. that.updateRangeTime()
  875. uni.getStorage({
  876. key: 'group',
  877. success: function(res) {
  878. that.form.productGroups = res.data
  879. }
  880. })
  881. }
  882. }
  883. </script>
  884. <style lang="scss" scoped>
  885. .creat {
  886. width: 100vw;
  887. height: 100vh;
  888. background: #F7F8FC;
  889. display: flex;
  890. flex-direction: column;
  891. justify-content: space-between;
  892. /*#ifdef APP-PLUS*/
  893. .top {
  894. width: 100%;
  895. height: var(--status-bar-height);
  896. background-color: #fff;
  897. }
  898. /*#endif*/
  899. .head {
  900. width: 100%;
  901. height: 112rpx;
  902. padding: 32rpx 24rpx;
  903. display: flex;
  904. align-items: center;
  905. background-color: #fff;
  906. position: relative;
  907. .cuIcon-back {
  908. font-size: 40rpx;
  909. margin-right: 40rpx;
  910. }
  911. .case {
  912. font-size: 36rpx;
  913. font-weight: 600;
  914. position: absolute;
  915. top: 50%;
  916. left: 50%;
  917. transform: translate(-50%, -50%);
  918. }
  919. .step {
  920. position: absolute;
  921. right: 20rpx;
  922. }
  923. }
  924. .content {
  925. width: 100%;
  926. flex: 1;
  927. padding: 24rpx;
  928. overflow-y: auto;
  929. .prompt {
  930. font-weight: 400;
  931. font-size: 28rpx;
  932. color: #999999;
  933. // padding: 10rpx 0;
  934. margin-bottom: 18rpx;
  935. }
  936. .titl {
  937. width: 100%;
  938. // height: 60rpx;
  939. font-weight: 600;
  940. font-size: 32rpx;
  941. color: #333333;
  942. margin-bottom: 16rpx;
  943. }
  944. .form {
  945. background-color: #fff;
  946. padding: 16rpx;
  947. border-radius: 16rpx;
  948. .item {
  949. width: 100%;
  950. height: 58rpx;
  951. border-bottom: 1px solid #EEEEEE;
  952. display: flex;
  953. // align-items: center;
  954. padding-bottom: 16rpx;
  955. margin-bottom: 16rpx;
  956. .label {
  957. margin-right: 20rpx;
  958. font-weight: 600;
  959. font-size: 28rpx;
  960. min-width: 126rpx;
  961. span {
  962. color: red;
  963. }
  964. }
  965. .picker {
  966. flex: 1;
  967. display: flex;
  968. align-items: center;
  969. justify-content: space-between;
  970. font-size: 28rpx;
  971. color: #999999;
  972. }
  973. .set {
  974. display: flex;
  975. justify-content: flex-end;
  976. ::v-deep.u-input {
  977. text-align: right !important;
  978. }
  979. }
  980. }
  981. .spray {
  982. .label {
  983. height: 57rpx;
  984. margin-right: 20rpx;
  985. font-weight: 600;
  986. font-size: 28rpx;
  987. min-width: 126rpx;
  988. margin-bottom: 16rpx;
  989. .change {
  990. display: flex;
  991. align-items: center;
  992. font-weight: 400;
  993. span {
  994. display: flex;
  995. align-items: center;
  996. margin-left: 30rpx;
  997. }
  998. image {
  999. width: 36rpx;
  1000. height: 36rpx;
  1001. font-size: 28rpx;
  1002. margin-right: 4rpx;
  1003. }
  1004. }
  1005. }
  1006. .spray_items {
  1007. .spra {
  1008. height: 106rpx;
  1009. margin-bottom: 32rpx;
  1010. display: flex;
  1011. align-items: start;
  1012. .square {
  1013. margin-right: 12rpx;
  1014. image {
  1015. width: 30rpx;
  1016. height: 40rpx;
  1017. }
  1018. }
  1019. .name {
  1020. display: flex;
  1021. font-size: 28rpx;
  1022. margin-bottom: 16rpx;
  1023. }
  1024. .price {
  1025. height: 49rpx;
  1026. display: flex;
  1027. justify-content: space-between;
  1028. .option {
  1029. display: flex;
  1030. align-items: center;
  1031. font-size: 26rpx;
  1032. color: #666666;
  1033. input {
  1034. height: 49rpx;
  1035. width: 160rpx;
  1036. background: #F7F8FC;
  1037. border-radius: 4rpx;
  1038. margin-left: 10rpx;
  1039. text-align: center;
  1040. font-size: 26rpx;
  1041. color: #666666;
  1042. }
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. .upload {
  1049. display: block;
  1050. height: auto;
  1051. .tips {
  1052. font-size: 20rpx;
  1053. color: #999999;
  1054. margin-bottom: 16rpx;
  1055. margin-top: 10rpx;
  1056. }
  1057. }
  1058. .textarea {
  1059. width: 100%;
  1060. height: 196rpx;
  1061. background: #F7F8FC;
  1062. border-radius: 4rpx;
  1063. padding: 12rpx 16rpx;
  1064. font-size: 26rpx;
  1065. margin-top: 12rpx;
  1066. }
  1067. .num {
  1068. width: 100%;
  1069. text-align: right;
  1070. font-size: 24rpx;
  1071. color: #999999;
  1072. margin-top: 6rpx;
  1073. }
  1074. }
  1075. }
  1076. .btn {
  1077. width: 100%;
  1078. height: 112rpx;
  1079. background-color: #fff;
  1080. display: flex;
  1081. justify-content: center;
  1082. align-items: center;
  1083. .next {
  1084. width: 672rpx;
  1085. height: 76rpx;
  1086. border-radius: 54rpx;
  1087. border: 1px solid #449AFF;
  1088. margin: 0 auto;
  1089. display: flex;
  1090. justify-content: center;
  1091. align-items: center;
  1092. font-size: 28rpx;
  1093. color: #449AFF;
  1094. }
  1095. .handle {
  1096. width: 100%;
  1097. display: flex;
  1098. justify-content: space-around;
  1099. .back {
  1100. width: 205rpx;
  1101. height: 76rpx;
  1102. border-radius: 54rpx;
  1103. border: 1px solid #449AFF;
  1104. display: flex;
  1105. align-items: center;
  1106. justify-content: center;
  1107. font-size: 28rpx;
  1108. color: #449AFF;
  1109. }
  1110. .submit {
  1111. width: 443rpx;
  1112. height: 76rpx;
  1113. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1114. border-radius: 53rpx;
  1115. display: flex;
  1116. align-items: center;
  1117. justify-content: center;
  1118. font-size: 28rpx;
  1119. color: #FFFFFF;
  1120. }
  1121. }
  1122. }
  1123. .popup {
  1124. width: 100vw;
  1125. height: 100vh;
  1126. position: fixed;
  1127. top: 0;
  1128. left: 0;
  1129. background: rgba(0, 0, 0, 0.4);
  1130. display: flex;
  1131. align-items: flex-end;
  1132. z-index: 99;
  1133. .model {
  1134. width: 100%;
  1135. background-color: #fff;
  1136. border-radius: 20rpx 20rpx 0rpx 0rpx;
  1137. padding: 0rpx 24rpx;
  1138. padding-bottom: 20rpx;
  1139. .title {
  1140. width: 100%;
  1141. height: 86rpx;
  1142. display: flex;
  1143. align-items: center;
  1144. justify-content: center;
  1145. border-bottom: 1px solid #EEEEEE;
  1146. position: relative;
  1147. image {
  1148. width: 40rpx;
  1149. height: 40rpx;
  1150. position: absolute;
  1151. right: 0px;
  1152. }
  1153. }
  1154. .tree {
  1155. display: flex;
  1156. height: 546rpx;
  1157. .left {
  1158. overflow-y: auto;
  1159. .item {
  1160. width: 224rpx;
  1161. height: 78rpx;
  1162. padding: 20rpx;
  1163. font-size: 26rpx;
  1164. }
  1165. .active {
  1166. background: rgba(68, 154, 255, 0.1);
  1167. color: #2983EC;
  1168. }
  1169. }
  1170. .border {
  1171. border-left: 1px solid #eeeeee;
  1172. border-right: 1px solid #eeeeee;
  1173. }
  1174. }
  1175. .sub {
  1176. display: flex;
  1177. justify-content: space-between;
  1178. margin-top: 16rpx;
  1179. border-top: 1px solid #eeeeee;
  1180. padding-top: 16rpx;
  1181. .submit {
  1182. width: 672rpx;
  1183. height: 76rpx;
  1184. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1185. border-radius: 53rpx;
  1186. display: flex;
  1187. align-items: center;
  1188. justify-content: center;
  1189. font-size: 28rpx;
  1190. color: #FFFFFF;
  1191. }
  1192. }
  1193. }
  1194. }
  1195. }
  1196. ::v-deep.u-upload__button {
  1197. width: 250rpx !important;
  1198. height: 250rpx !important;
  1199. }
  1200. .exchange-input {
  1201. display: flex;
  1202. justify-content: space-between;
  1203. height: 65rpx;
  1204. background: #F7F8FC;
  1205. border-radius: 12rpx;
  1206. margin-bottom: 20rpx;
  1207. padding: 20rpx;
  1208. font-size: 28rpx;
  1209. width: 100%;
  1210. .exchange-all {
  1211. color: #333333;
  1212. font-size: 28rpx;
  1213. }
  1214. input {
  1215. font-size: 28rpx;
  1216. }
  1217. }
  1218. </style>