creatProduct.vue 30 KB

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