creatProduct.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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 class="form-input" readonly 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. <refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel"
  266. @confirm="saveFound" @close="cutRule"
  267. />
  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. <!-- 时间组件 -->
  305. <rangTime ref="rangTime" :mode="mode" :title="timeTitle" @onSubmit="onEndTimeChange" />
  306. </view>
  307. </template>
  308. <script>
  309. import rangTime from '../../components/dengrq-datetime-picker/dateSelector/index.vue'
  310. import refund from '@/components/product/refund.vue'
  311. import configService from '../../common/service/config.service'
  312. import {
  313. nextTick
  314. } from "vue"
  315. export default {
  316. components: {
  317. rangTime,
  318. refund
  319. },
  320. data() {
  321. return {
  322. tabIndex: '0',
  323. mode: 1,
  324. form: {
  325. instructions: '',
  326. preBook: 0,
  327. merchantId: null
  328. // categoryId:'',
  329. // productName: '',
  330. // productImage: '',
  331. // checked: null,
  332. // num: 0,
  333. // refundLabel:null,
  334. // refundConfirm:null
  335. },
  336. fmImageList: [], //封面图回显
  337. xqImage: [], //详情图回显
  338. showRule: '', //显示退款规则文字
  339. action: configService.apiUrl + '/sys/common/upload', //图片上传地址
  340. // action: 'http://192.168.0.36:8080/jeecg-boot/sys/common/upload', //图片上传地址
  341. schedule: 1, //进度
  342. fileList: [],
  343. selectedTime: null,
  344. isSelectDate: false,
  345. isRefund: false,
  346. isSelectType: false,
  347. treeLeft: [], //一级列表
  348. treeCenter: [], //二级列表
  349. treeRight: [], //三级列表
  350. currentLeft: 0, //一级选中
  351. currentCenter: 0, //二级选中
  352. currentRight: 0, //三级选中
  353. productType: [], //选中的商品分类id
  354. selectTypeList: [], //选中的商品分类名称
  355. showText: '',
  356. showDate: '',
  357. showSellDate: '',
  358. makeChecked: false,
  359. // imageHttp: 'http://192.168.0.36:8080/jeecg-boot/', //上传图片前缀+
  360. imageHttp: configService.apiUrl + '/', //上传图片前缀+
  361. productId: '',
  362. jindouChecked: false,
  363. jifenChecked: false,
  364. selectVaule: 0, //钣金喷漆选择
  365. all: false, //是否全选
  366. reverse: false, //是否反选
  367. selectProductSunItem:[],
  368. timeTitle:'选择售卖时间',
  369. // 商品分组列表
  370. showGroupPicker: false,
  371. groupOptions: [],
  372. }
  373. },
  374. mounted() {
  375. this.getProductGroup()
  376. this.getLeftTree()
  377. this.getForm()
  378. },
  379. onLoad(options) {
  380. if (options.productId) {
  381. this.productId = options.productId
  382. }
  383. // 商品类型
  384. if (options.tabIndex) {
  385. this.tabIndex = options.tabIndex
  386. }
  387. },
  388. onShow() {
  389. uni.getStorage({
  390. key: 'login_user_info',
  391. success: (res) => {
  392. this.form.merchantId = res.data.merchantId
  393. }
  394. })
  395. uni.getStorage({
  396. key: 'group',
  397. success: (res) => {
  398. this.form.productGroups = res.data
  399. }
  400. })
  401. this.updateRangeTime()
  402. },
  403. methods: {
  404. //全选
  405. allSelect() {
  406. this.all = true
  407. this.reverse = false
  408. this.form.specItems.forEach(item => {
  409. item.replaced = true
  410. })
  411. },
  412. //反选
  413. reverseSelsct() {
  414. this.reverse = true
  415. this.all = false
  416. this.form.specItems.forEach(item => {
  417. item.replaced = !item.replaced
  418. })
  419. },
  420. //选中
  421. select(item) {
  422. item.replaced = !item.replaced
  423. // const index = this.form.specItems.findIndex(i => i.id === item.id);
  424. // if (index !== -1) {
  425. // this.form.specItems.splice(index, 1, {
  426. // ...item,
  427. // replaced: !item.replaced
  428. // });
  429. // }
  430. },
  431. // 上传封面图成功回调
  432. handleSuccess(res, index, lists) {
  433. this.form.productImage = this.imageHttp + res.message
  434. },
  435. // 移除封面图文件回调
  436. handleRemove(index, lists) {
  437. this.fmImageList = [];
  438. },
  439. //上传详情图
  440. detailsSuccess(res, index, lists) {
  441. console.log(lists)
  442. this.processImageList(lists);
  443. this.xqImage = lists
  444. },
  445. detailsRemove(index, lists) {
  446. this.xqImage = lists
  447. this.processImageList(lists);
  448. },
  449. // 处理图片列表,生成URL字符串
  450. processImageList(lists) {
  451. let temp = [];
  452. lists.forEach(item => {
  453. if (item.response && item.response.message) {
  454. temp.push(this.imageHttp + item.response.message);
  455. } else if (item.url) {
  456. // 处理已存在的图片
  457. temp.push(item.url);
  458. }
  459. });
  460. this.form.detailImages = temp.join(',');
  461. console.log('当前图片URL字符串:', this.form.detailImages);
  462. },
  463. //下一步
  464. next() {
  465. let temp = []
  466. if(this.form.specItems){
  467. this.form.specItems.forEach(item => {
  468. // item.replaced = true
  469. if(item.replaced){
  470. this.selectProductSunItem.push(item)
  471. }
  472. })
  473. // this.form.specItems = temp
  474. }
  475. //基础信息必填提示
  476. if (!this.form.categoryId) {
  477. uni.showToast({
  478. title: '请选择商品分类',
  479. icon: 'none'
  480. });
  481. return
  482. }
  483. if (!this.form.productName) {
  484. uni.showToast({
  485. title: '请输入商品名称',
  486. icon: 'none'
  487. });
  488. return
  489. }
  490. if (!this.form.productImage) {
  491. uni.showToast({
  492. title: '请上传商品封面图',
  493. icon: 'none'
  494. });
  495. return
  496. }
  497. if (this.tabIndex == '0' && !this.form.detailImages) {
  498. uni.showToast({
  499. title: '请上传商品详情图',
  500. icon: 'none'
  501. });
  502. return
  503. }
  504. if (!this.form.price) {
  505. // if (!this.form.price && !this.form.categoryId == '1945013773786701826') {
  506. uni.showToast({
  507. title: '请输入商品原价',
  508. icon: 'none'
  509. });
  510. return
  511. }
  512. // if (!this.form.soldPrice && !this.form.categoryId == '1945013773786701826') {
  513. if (!this.form.soldPrice) {
  514. uni.showToast({
  515. title: '请输入商品售价',
  516. icon: 'none'
  517. });
  518. return
  519. } else if (this.form.categoryId == '1945013773786701826' && this.selectProductSunItem.length ==0) {
  520. uni.showToast({
  521. title: '请选择最少一个配置',
  522. icon: 'none'
  523. });
  524. } else {
  525. this.schedule += 1
  526. }
  527. },
  528. // 跳转至组合商品页
  529. goGroup() {
  530. // if(this.tabIndex==0){
  531. uni.navigateTo({
  532. url: '/pages/product/group'
  533. })
  534. // }
  535. },
  536. //返回
  537. back() {
  538. uni.navigateTo({
  539. url: '/pages/product/index'
  540. })
  541. },
  542. // 处理 confirm 事件,接收子组件传递的时间段数据
  543. handleConfirm(time) {
  544. this.selectedTime = time; // 保存时间段数据
  545. this.isSelectDate = false
  546. },
  547. //隐藏弹窗
  548. closeSelectDate() {
  549. this.isSelectDate = false
  550. },
  551. //跳转至可用时间
  552. setUsable() {
  553. let str = this.$u.queryParams({ useType: this.form.useType })
  554. uni.navigateTo({
  555. url: `/pages/product/usable${str}`
  556. })
  557. },
  558. // 更新时间
  559. updateRangeTime() {
  560. uni.getStorage({
  561. key: 'smdate',
  562. success: (res) => {
  563. if (res.data.useType == 2) {
  564. this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
  565. this.form.availableStartDate = res.data.availableStartDate
  566. this.form.availableEndDate = res.data.availableEndDate
  567. this.form.expirationDays = null
  568. this.form.useType = 2
  569. } else if (res.data.useType == 1) {
  570. this.form.expirationDays = res.data.expirationDays
  571. this.form.availableEndDate = null
  572. this.form.availableStartDate = null
  573. this.form.useType = 1
  574. this.$nextTick(() => {
  575. this.showSellDate = res.data.expirationDays + '天后失效'
  576. });
  577. } else if (res.data.useType == 3) {
  578. this.form.useType = 3
  579. this.showSellDate = '长期有效'
  580. }
  581. }
  582. })
  583. },
  584. // 保存退款规则
  585. saveFound(rules) {
  586. console.log(rules)
  587. this.form.refundConfirm = rules.refundConfirm.refundConfirm
  588. this.form.refundLabel = rules.refundLabel.refundLabel
  589. let value1 = []
  590. value1.push(rules.refundConfirm.name, rules.refundLabel.name)
  591. this.showRule = value1.join("·")
  592. // this.selectedRules = rules;
  593. this.isRefund = false
  594. },
  595. cutRule() {
  596. this.isRefund = false
  597. },
  598. //获取商品分类一级列表
  599. getLeftTree() {
  600. this.$http.get("/sys/category/childList?pid=" + '1889836358116098050', {}).then(res => {
  601. if (res.data.code == 0) {
  602. this.treeLeft = res.data.result
  603. if (this.treeLeft[0]) {
  604. this.getCenterTree(this.treeLeft[0].id)
  605. }
  606. }
  607. })
  608. },
  609. //获取商品分类二级列表
  610. getCenterTree(id) {
  611. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  612. if (res.data.code == 0) {
  613. this.treeCenter = res.data.result
  614. if (this.treeCenter[0]) {
  615. // this.getRightTree(this.treeCenter[0].id)
  616. }
  617. }
  618. })
  619. },
  620. //获取商品分类三级列表
  621. getRightTree(id) {
  622. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  623. if (res.data.code == 0) {
  624. this.treeRight = res.data.result
  625. }
  626. })
  627. },
  628. selectProductType() {
  629. if (this.tabIndex == '0') {
  630. this.isSelectType = true
  631. this.showText = ''
  632. this.productType = []
  633. this.selectTypeList = []
  634. this.currentLeft = null
  635. this.currentCenter = null
  636. this.currentRight = null
  637. }
  638. },
  639. selectGrouping() {
  640. if (this.tabIndex == '0') {
  641. this.showGroupPicker = true
  642. }
  643. },
  644. //选中一级
  645. selectLeft(item, index) {
  646. this.currentLeft = index
  647. this.currentCenter = null
  648. this.currentRight = null
  649. this.treeCenter = []
  650. this.treeRight = []
  651. this.productType = []
  652. this.selectTypeList = []
  653. this.productType.push(item.id)
  654. this.selectTypeList.push(item.name)
  655. this.getCenterTree(item.id)
  656. },
  657. //选中二级
  658. selectRight(item, index) {
  659. this.getRightTree(this.treeCenter[0].id)
  660. this.currentCenter = index
  661. this.currentRight = null
  662. if (this.selectTypeList.length >= 2) {
  663. this.productType.splice(1, 2)
  664. this.selectTypeList.splice(1, 2)
  665. }
  666. this.productType.push(item.id)
  667. this.selectTypeList.push(item.name)
  668. this.getRightTree(item.id)
  669. },
  670. //选中三级
  671. selectLast(item, index) {
  672. if (this.selectTypeList.length >= 3) {
  673. this.productType.splice(2, 1)
  674. this.selectTypeList.splice(2, 1)
  675. }
  676. this.productType.push(item.id)
  677. this.selectTypeList.push(item.name)
  678. this.currentRight = index
  679. },
  680. //确定分类
  681. selectType() {
  682. this.isSelectType = false
  683. this.form.categoryId = this.productType.join(',')
  684. this.showText = this.selectTypeList.join('·')
  685. },
  686. //关闭选择分类弹窗
  687. closePopup() {
  688. this.isSelectType = false
  689. },
  690. //获取商品分组列表
  691. getProductGroup() {
  692. this.$http.get("/localProductGrouping/localProductGrouping/getAppList?sourceType=1").then(res => {
  693. if (res.data.success) {
  694. this.groupOptions = res.data.result || []
  695. }
  696. })
  697. },
  698. // 确定分组
  699. groupConfirm(e) {
  700. this.form.groupingId = e[0].value
  701. this.form.groupingName = e[0].label
  702. this.showGroupPicker = false;
  703. },
  704. selectDate() {
  705. // this.isSelectDate = true
  706. this.$refs.rangTime.open()
  707. },
  708. onEndTimeChange(val) {
  709. this.form.saleStartDate = val.startDate
  710. this.form.saleEndDate = val.endDate
  711. this.showDate = val.startDate + ' ~ ' + val.endDate
  712. this.$forceUpdate(); // 强制刷新视图
  713. },
  714. //提交审核
  715. submit() {
  716. console.log(this.form)
  717. this.form.specItems = this.selectProductSunItem
  718. this.makeChecked ? this.form.preBook = 1 : this.form.preBook = 0
  719. if (!this.form.saleStartDate) {
  720. uni.showToast({
  721. title: '请设置售卖时间',
  722. icon: 'none'
  723. });
  724. return
  725. } else if (!this.form.stockQuantity) {
  726. uni.showToast({
  727. title: '请输入商品库存',
  728. icon: 'none'
  729. });
  730. return
  731. } else if (!this.form.useType) {
  732. uni.showToast({
  733. title: '请选择可用时间',
  734. icon: 'none'
  735. });
  736. return
  737. // } else if (this.tabIndex != 1 && (this.form.refundConfirmName == null || this.form.refundLabelName == null)) {
  738. } else if (this.tabIndex != 1 && (this.form.refundConfirm == null || this.form.refundLabel == null)) {
  739. uni.showToast({
  740. title: '请选择退款标签',
  741. icon: 'none'
  742. });
  743. return
  744. } else {
  745. if (this.productId == '') {
  746. this.$http.post("/app/product/add", this.form).then(res => {
  747. if (res.data.code == 200) {
  748. uni.showToast({
  749. title: '添加成功',
  750. icon: 'none'
  751. });
  752. this.back()
  753. uni.removeStorage({
  754. key: 'smdate',
  755. });
  756. uni.removeStorage({
  757. key: 'group',
  758. });
  759. } else {
  760. uni.showToast({
  761. title: res.data.message,
  762. icon: 'none'
  763. });
  764. }
  765. })
  766. } else {
  767. this.form.productId = this.productId
  768. this.$http.post("/app/product/edit", this.form).then(res => {
  769. if (res.data.code == 200) {
  770. uni.showToast({
  771. title: '编辑成功',
  772. icon: 'none'
  773. });
  774. this.back()
  775. } else {
  776. uni.showToast({
  777. icon: 'none',
  778. title: res.data.message
  779. })
  780. }
  781. uni.removeStorage({
  782. key: 'smdate',
  783. });
  784. uni.removeStorage({
  785. key: 'group',
  786. });
  787. })
  788. }
  789. }
  790. },
  791. //回显数据
  792. getForm() {
  793. this.$http.get("/app/product/queryById?id=" + this.productId, {}).then(res => {
  794. if (res.data.code == 200) {
  795. this.form = res.data.result
  796. this.jifenChecked = res.data.result.integralAward ? true : false
  797. this.jindouChecked = res.data.result.goldAward ? true : false
  798. this.showText = res.data.result.productCategory
  799. this.fmImageList.push({
  800. url: res.data.result.productImage
  801. })
  802. if (res.data.result.detailImages) {
  803. let xqtemp = []
  804. xqtemp = res.data.result.detailImages.split(',')
  805. xqtemp.map(item => {
  806. this.xqImage.push({
  807. url: item
  808. })
  809. })
  810. console.log(this.xqImage)
  811. }
  812. this.showDate = res.data.result.saleStartDate.slice(0, 10) + ' ~ ' + res.data.result.saleEndDate.slice(0,
  813. 10)
  814. if (res.data.result.useType == 2) {
  815. this.showSellDate = res.data.result.availableStartDate.slice(0, 10) + '-' + res.data.result
  816. .availableEndDate.slice(0, 10)
  817. } else if (res.data.result.useType == 1) {
  818. this.showSellDate = res.data.result.expirationDays + '天后失效'
  819. }else if(res.data.result.useType == 3){
  820. this.showSellDate = '长期有效'
  821. }
  822. res.data.result.preBook == 0 ? this.makeChecked = false : this.makeChecked = true
  823. if (res.data.result.refundLabelName && res.data.result.refundConfirmName) {
  824. this.showRule = res.data.result.refundLabelName + '·' + res.data.result.refundConfirmName
  825. }
  826. console.log(this.showRule)
  827. uni.setStorage({
  828. key: 'group',
  829. data: res.data.result.productGroups
  830. })
  831. }
  832. })
  833. }
  834. }
  835. }
  836. </script>
  837. <style lang="scss" scoped>
  838. .creat {
  839. width: 100vw;
  840. height: 100vh;
  841. background: #F7F8FC;
  842. display: flex;
  843. flex-direction: column;
  844. justify-content: space-between;
  845. /*#ifdef APP-PLUS*/
  846. .top {
  847. width: 100%;
  848. height: var(--status-bar-height);
  849. background-color: #fff;
  850. }
  851. /*#endif*/
  852. .head {
  853. width: 100%;
  854. height: 112rpx;
  855. padding: 32rpx 24rpx;
  856. display: flex;
  857. align-items: center;
  858. background-color: #fff;
  859. position: relative;
  860. .cuIcon-back {
  861. font-size: 40rpx;
  862. margin-right: 40rpx;
  863. }
  864. .case {
  865. font-size: 36rpx;
  866. font-weight: 600;
  867. position: absolute;
  868. top: 50%;
  869. left: 50%;
  870. transform: translate(-50%, -50%);
  871. }
  872. .step {
  873. position: absolute;
  874. right: 20rpx;
  875. }
  876. }
  877. .content {
  878. width: 100%;
  879. flex: 1;
  880. padding: 24rpx;
  881. overflow-y: auto;
  882. .prompt {
  883. font-weight: 400;
  884. font-size: 28rpx;
  885. color: #999999;
  886. // padding: 10rpx 0;
  887. margin-bottom: 18rpx;
  888. }
  889. .titl {
  890. width: 100%;
  891. // height: 60rpx;
  892. font-weight: 600;
  893. font-size: 32rpx;
  894. color: #333333;
  895. margin-bottom: 16rpx;
  896. }
  897. .form {
  898. background-color: #fff;
  899. padding: 16rpx;
  900. border-radius: 16rpx;
  901. .item {
  902. width: 100%;
  903. height: 58rpx;
  904. border-bottom: 1px solid #EEEEEE;
  905. display: flex;
  906. // align-items: center;
  907. padding-bottom: 16rpx;
  908. margin-bottom: 16rpx;
  909. .label {
  910. margin-right: 20rpx;
  911. font-weight: 600;
  912. font-size: 28rpx;
  913. min-width: 126rpx;
  914. span {
  915. color: red;
  916. }
  917. }
  918. .picker {
  919. flex: 1;
  920. display: flex;
  921. align-items: center;
  922. justify-content: space-between;
  923. font-size: 28rpx;
  924. color: #999999;
  925. }
  926. .set {
  927. display: flex;
  928. justify-content: flex-end;
  929. ::v-deep.u-input {
  930. text-align: right !important;
  931. }
  932. }
  933. }
  934. .spray {
  935. .label {
  936. height: 57rpx;
  937. margin-right: 20rpx;
  938. font-weight: 600;
  939. font-size: 28rpx;
  940. min-width: 126rpx;
  941. margin-bottom: 16rpx;
  942. .change {
  943. display: flex;
  944. align-items: center;
  945. font-weight: 400;
  946. span {
  947. display: flex;
  948. align-items: center;
  949. margin-left: 30rpx;
  950. }
  951. image {
  952. width: 36rpx;
  953. height: 36rpx;
  954. font-size: 28rpx;
  955. margin-right: 4rpx;
  956. }
  957. }
  958. }
  959. .spray_items {
  960. .spra {
  961. height: 106rpx;
  962. margin-bottom: 32rpx;
  963. display: flex;
  964. align-items: start;
  965. .square {
  966. margin-right: 12rpx;
  967. image {
  968. width: 30rpx;
  969. height: 40rpx;
  970. }
  971. }
  972. .name {
  973. display: flex;
  974. font-size: 28rpx;
  975. margin-bottom: 16rpx;
  976. }
  977. .price {
  978. height: 49rpx;
  979. display: flex;
  980. justify-content: space-between;
  981. .option {
  982. display: flex;
  983. align-items: center;
  984. font-size: 26rpx;
  985. color: #666666;
  986. input {
  987. height: 49rpx;
  988. width: 160rpx;
  989. background: #F7F8FC;
  990. border-radius: 4rpx;
  991. margin-left: 10rpx;
  992. text-align: center;
  993. font-size: 26rpx;
  994. color: #666666;
  995. }
  996. }
  997. }
  998. }
  999. }
  1000. }
  1001. .upload {
  1002. display: block;
  1003. height: auto;
  1004. .tips {
  1005. font-size: 20rpx;
  1006. color: #999999;
  1007. margin-bottom: 16rpx;
  1008. margin-top: 10rpx;
  1009. }
  1010. }
  1011. .textarea {
  1012. width: 100%;
  1013. height: 196rpx;
  1014. background: #F7F8FC;
  1015. border-radius: 4rpx;
  1016. padding: 12rpx 16rpx;
  1017. font-size: 26rpx;
  1018. margin-top: 12rpx;
  1019. }
  1020. .num {
  1021. width: 100%;
  1022. text-align: right;
  1023. font-size: 24rpx;
  1024. color: #999999;
  1025. margin-top: 6rpx;
  1026. }
  1027. }
  1028. .form-input {
  1029. pointer-events: none;
  1030. }
  1031. ::v-deep .uni-input-input:disabled {
  1032. pointer-events: none;
  1033. }
  1034. }
  1035. .btn {
  1036. width: 100%;
  1037. height: 112rpx;
  1038. background-color: #fff;
  1039. display: flex;
  1040. justify-content: center;
  1041. align-items: center;
  1042. .next {
  1043. width: 672rpx;
  1044. height: 76rpx;
  1045. border-radius: 54rpx;
  1046. border: 1px solid #449AFF;
  1047. margin: 0 auto;
  1048. display: flex;
  1049. justify-content: center;
  1050. align-items: center;
  1051. font-size: 28rpx;
  1052. color: #449AFF;
  1053. }
  1054. .handle {
  1055. width: 100%;
  1056. display: flex;
  1057. justify-content: space-around;
  1058. .back {
  1059. width: 205rpx;
  1060. height: 76rpx;
  1061. border-radius: 54rpx;
  1062. border: 1px solid #449AFF;
  1063. display: flex;
  1064. align-items: center;
  1065. justify-content: center;
  1066. font-size: 28rpx;
  1067. color: #449AFF;
  1068. }
  1069. .submit {
  1070. width: 443rpx;
  1071. height: 76rpx;
  1072. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1073. border-radius: 53rpx;
  1074. display: flex;
  1075. align-items: center;
  1076. justify-content: center;
  1077. font-size: 28rpx;
  1078. color: #FFFFFF;
  1079. }
  1080. }
  1081. }
  1082. .popup {
  1083. width: 100vw;
  1084. height: 100vh;
  1085. position: fixed;
  1086. top: 0;
  1087. left: 0;
  1088. background: rgba(0, 0, 0, 0.4);
  1089. display: flex;
  1090. align-items: flex-end;
  1091. z-index: 99;
  1092. .model {
  1093. width: 100%;
  1094. background-color: #fff;
  1095. border-radius: 20rpx 20rpx 0rpx 0rpx;
  1096. padding: 0rpx 24rpx;
  1097. padding-bottom: 20rpx;
  1098. .title {
  1099. width: 100%;
  1100. height: 86rpx;
  1101. display: flex;
  1102. align-items: center;
  1103. justify-content: center;
  1104. border-bottom: 1px solid #EEEEEE;
  1105. position: relative;
  1106. image {
  1107. width: 40rpx;
  1108. height: 40rpx;
  1109. position: absolute;
  1110. right: 0px;
  1111. }
  1112. }
  1113. .tree {
  1114. display: flex;
  1115. height: 546rpx;
  1116. .left {
  1117. overflow-y: auto;
  1118. .item {
  1119. width: 224rpx;
  1120. height: 78rpx;
  1121. padding: 20rpx;
  1122. font-size: 26rpx;
  1123. }
  1124. .active {
  1125. background: rgba(68, 154, 255, 0.1);
  1126. color: #2983EC;
  1127. }
  1128. }
  1129. .border {
  1130. border-left: 1px solid #eeeeee;
  1131. border-right: 1px solid #eeeeee;
  1132. }
  1133. }
  1134. .sub {
  1135. display: flex;
  1136. justify-content: space-between;
  1137. margin-top: 16rpx;
  1138. border-top: 1px solid #eeeeee;
  1139. padding-top: 16rpx;
  1140. .submit {
  1141. width: 672rpx;
  1142. height: 76rpx;
  1143. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1144. border-radius: 53rpx;
  1145. display: flex;
  1146. align-items: center;
  1147. justify-content: center;
  1148. font-size: 28rpx;
  1149. color: #FFFFFF;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. }
  1155. ::v-deep.u-upload__button {
  1156. width: 250rpx !important;
  1157. height: 250rpx !important;
  1158. }
  1159. .exchange-input {
  1160. display: flex;
  1161. justify-content: space-between;
  1162. height: 65rpx;
  1163. background: #F7F8FC;
  1164. border-radius: 12rpx;
  1165. margin-bottom: 20rpx;
  1166. padding: 20rpx;
  1167. font-size: 28rpx;
  1168. width: 100%;
  1169. .exchange-all {
  1170. color: #333333;
  1171. font-size: 28rpx;
  1172. }
  1173. input {
  1174. font-size: 28rpx;
  1175. }
  1176. }
  1177. </style>