creatProduct.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928
  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. <!-- 第一步 -->
  12. <view class="form" v-show="schedule == 1">
  13. <view class="item">
  14. <view class="titl">
  15. 商品信息
  16. </view>
  17. </view>
  18. <!-- <view class="titl">
  19. 商品信息
  20. </view> -->
  21. <view class="item">
  22. <view class="label">
  23. 商品名称<span v-if="tabIndex == '0'">*</span>
  24. </view>
  25. <view class="picker">
  26. <u-input :disabled="tabIndex == 1" v-model="form.productName" placeholder="请输入" />
  27. </view>
  28. </view>
  29. <view class="item">
  30. <view class="label">
  31. 商品分类<span v-if="tabIndex == '0'">*</span>
  32. </view>
  33. <view class="picker" @click="selectProductType">
  34. <span v-if="showText == ''">请选择</span>
  35. <span v-else style="color: #333333;">{{ showText }}</span>
  36. <u-icon name="arrow-right"></u-icon>
  37. </view>
  38. </view>
  39. <!-- <u-form-item label="车辆类型" prop="categoryName" borderBottom required
  40. @click="showcategory = true">
  41. <u--input v-model="userInfo.categoryName" disabled disabledColor="#ffffff" placeholder="请选择车辆类型"
  42. border="none"></u--input>
  43. <u-icon slot="right" name="arrow-right"></u-icon>
  44. </u-form-item> -->
  45. <view class="item">
  46. <view class="label">
  47. 商品分组<span v-if="tabIndex == '0'">*</span>
  48. </view>
  49. <view class="picker" @click="selectGrouping">
  50. <span v-if="form.groupingName == ''">请选择</span>
  51. <span v-else style="color: #333333;">{{ form.groupingName }}</span>
  52. <u-icon name="arrow-right"></u-icon>
  53. </view>
  54. </view>
  55. <view class="item upload">
  56. <view class="label">
  57. 商品封面图<span v-if="tabIndex == '0'">*</span>
  58. </view>
  59. <!-- <view class="tips">
  60. 支持jpg、png格式
  61. </view> -->
  62. <view class="tips">
  63. 建议尺寸750*750或750*1000,大小在2M以内,最多上传5张
  64. </view>
  65. <view v-if="tabIndex == 1">
  66. <image v-for="(val, index) in fmImageList" :key="index" :src="val.url" mode=""
  67. style="width: 140rpx;height:140rpx;border-radius: 4px; border: 1px solid #ebecee;margin-right:20rpx;margin-bottom:10rpx">
  68. </image>
  69. </view>
  70. <u-upload v-else ref="uUpload" :action="action" :file-list="fmImageList" @on-success="handleSuccess"
  71. @on-remove="handleRemove" max-count="5" width="140rpx" height="140rpx"></u-upload>
  72. </view>
  73. <view class="item upload">
  74. <view class="label">
  75. 主图视频
  76. </view>
  77. <view class="tips">
  78. 上传视频时封面图片尺寸建议与商品图片一致
  79. </view>
  80. <view class="customize">
  81. <view class="business-img">
  82. <view class="uni-uploader__file" v-if="video">
  83. <view class="uploader_video">
  84. <uni-icons class="icon iconfont icon-cuo" type="trash-filled" size="20"
  85. @tap="delectVideo"></uni-icons>
  86. <video :src="video" class="video-container"></video>
  87. </view>
  88. </view>
  89. <image v-if="tabIndex != '1' && !video" src="/static/store/upload2.png" mode="" @tap="chooseVideo()">
  90. </image>
  91. </view>
  92. <!-- <view class="business-prompt">
  93. 最多上传1个视频,大小不超过50M,建议宽高比9:16
  94. </view> -->
  95. </view>
  96. </view>
  97. <view class="item upload">
  98. <view class="label">
  99. 商品详情页<span v-if="tabIndex == '0'">*</span>
  100. </view>
  101. <!-- 引用富文本编辑器组件 -->
  102. <Editor :readOnly="tabIndex == 1" :toolbarConfig="toolbarConfig" @init="onEditorInit" @input="onEditorInput"
  103. @upinImage="handleEditorImageUpload" />
  104. </view>
  105. <view class="item upload" style="border: none;">
  106. <view class="label">
  107. 搜索关键字<span v-if="tabIndex == '0'">*</span>
  108. </view>
  109. <view class="textareas">
  110. <u-input :disabled="tabIndex == 1" v-model="form.searchKeywords" type="textarea" placeholder="请输入"
  111. maxlength="500" />
  112. </view>
  113. </view>
  114. <!-- <view class="item" v-if="form.categoryId != '1945013773786701826'">
  115. <view class="label">
  116. 原价<span>*</span>
  117. </view>
  118. <view class="picker">
  119. <u-input :disabled="tabIndex == 1" v-model="form.price" placeholder="输入商品原价" />
  120. </view>
  121. <view class="unit">
  122. </view>
  123. </view>
  124. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  125. <view class="label">
  126. 实际售价<span>*</span>
  127. </view>
  128. <view class="picker">
  129. <u-input type="num" :disabled="form.isUpdatePrice == 0" v-model="form.soldPrice" placeholder="输入客户实际支付价" />
  130. </view>
  131. <view class="unit">
  132. </view>
  133. </view>
  134. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  135. <view class="label">
  136. 组合套餐
  137. </view>
  138. <view class="picker set" @click="goGroup">
  139. 去设置
  140. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  141. </view>
  142. </view> -->
  143. <!-- 钣金喷漆 -->
  144. <view class="spray" v-if="form.categoryId == '1945013773786701826'">
  145. <view class="label" style="width: 100%;display: flex;justify-content: space-between;align-items: center;">
  146. 商品规格
  147. <view class="change">
  148. <span @click="allSelect">
  149. <image src="/static/product/select.png" mode="" v-if="all"></image>
  150. <image src="/static/product/round.png" mode="" v-else></image>
  151. 全选
  152. </span>
  153. <span @click="reverseSelsct">
  154. <image src="/static/product/select.png" mode="" v-if="reverse"></image>
  155. <image src="/static/product/round.png" mode="" v-else></image>
  156. 反选
  157. </span>
  158. </view>
  159. </view>
  160. <view class="spray_items">
  161. <view class="spra" v-for="(item, index) in form.specItems" :key="item.craftId">
  162. <view class="square" @click="select(item)">
  163. <image src="/static/product/square_select.png" mode="" v-if="item.replaced == true"></image>
  164. <image src="/static/product/square.png" mode="" v-else></image>
  165. </view>
  166. <view class="right">
  167. <view class="name">
  168. <!-- {{item.craftId}} -->
  169. {{ item.partName }} {{ item.positionName }} {{ item.craftName }}
  170. </view>
  171. <view class="price">
  172. <view class="option">原价<input v-model="item.price" placeholder="输入商品原价" style="height: 49rpx;" />
  173. </view>
  174. <view class="option">参考售价<input v-model="item.soldPrice" placeholder="输入商品参考售价" /></view>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 第二步 -->
  182. <view class="form" v-show="schedule == 2">
  183. <view class="item">
  184. <view class="titl">
  185. 销售信息
  186. </view>
  187. </view>
  188. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  189. <view class="label">
  190. 商品售价<span>*</span>
  191. </view>
  192. <view class="picker">
  193. <u-input type="number" v-model.number="form.price" placeholder="请输入"
  194. @blur="checkPriceAndSoldPrice('price')" />
  195. </view>
  196. <view class="unit">
  197. </view>
  198. </view>
  199. <view class="item" v-if="form.categoryId != '1945013773786701826'">
  200. <view class="label">
  201. 商品市场价<span>*</span>
  202. </view>
  203. <view class="picker">
  204. <u-input type="number" v-model.number="form.soldPrice" placeholder="请输入"
  205. @blur="checkPriceAndSoldPrice('soldPrice')" />
  206. </view>
  207. <view class="unit">
  208. </view>
  209. </view>
  210. <view class="item_tips">
  211. 划线价格
  212. </view>
  213. <view class="item">
  214. <view class="label">
  215. 虚拟销量
  216. </view>
  217. <view class="picker">
  218. <u-input type="num" :disabled="tabIndex == 1" v-model="form.virtualSales" placeholder="请输入" />
  219. </view>
  220. </view>
  221. <view class="item_tips">
  222. 实际销量大于虚拟销量时,系统自动切换为真实销量展示
  223. </view>
  224. <view class="item upload">
  225. <view class="label">
  226. 售卖时间<span v-if="tabIndex == '1'">*</span>
  227. </view>
  228. <view>
  229. <u-radio-group v-model="form.sellingTimeType"
  230. style="width: 100%;background-color: #ffffff;padding: 16rpx 0;border-radius: 16rpx;">
  231. <u-radio name="1" style="width: 100%;">
  232. <view>
  233. 不限制
  234. </view>
  235. </u-radio>
  236. <u-radio name="2" style="width: 100%;margin-top: 16rpx;">
  237. <span>
  238. 每天
  239. </span>
  240. <span v-if="form.sellingTimeType == '2'" style="margin-left: 26rpx;">
  241. <u-button type="primary" size="mini" @click="selectSaleDate">添加时间</u-button>
  242. </span>
  243. </u-radio>
  244. <!-- 每天售卖时间选择 -->
  245. <uni-card v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0"
  246. :is-shadow="false" is-full style="border:1rpx solid #E5E5E5;margin-top: 16rpx;">
  247. <view v-for="item, index in form.sellingDay" :key="index"
  248. style="display: flex; justify-content: space-between;">
  249. <span>{{ item[0] }}</span>
  250. <span style="color: #dd524d;" @click="deleteTime(index)"><u-icon name="minus-circle-fill"
  251. style="margin-left: 17rpx;"></u-icon></span>
  252. </view>
  253. </uni-card>
  254. <u-radio name="3" style="width: 100%;margin-top: 16rpx;">
  255. <span>
  256. 每周
  257. </span>
  258. </u-radio>
  259. </u-radio-group>
  260. <view class="item_tips saletime" v-show="form.sellingTimeType == '2' && form.sellingDay.length == 0">
  261. 请添加起止时间段
  262. </view>
  263. <!-- 每周售卖时间选择 -->
  264. <uni-table v-show="form.sellingTimeType == '3'">
  265. <!-- 表头 -->
  266. <uni-tr class="table-header">
  267. <uni-th width="200rpx" align="left"><u-checkbox v-model:checked="allChecked"
  268. @change="handleAllCheckChange"></u-checkbox>工作日</uni-th>
  269. <uni-th align="center">时间</uni-th>
  270. <uni-th width="100rpx" align="center">操作</uni-th>
  271. </uni-tr>
  272. <!-- 数据行 -->
  273. <uni-tr v-for="(item, index) in form.localProductSellingWeeks" :key="index" class="table-row">
  274. <uni-td width="200rpx" align="left">
  275. <u-checkbox v-model="item.checked"
  276. @change="handleItemCheckChange($event, item, index)"></u-checkbox>{{
  277. item.weekDay }}
  278. </uni-td>
  279. <uni-td align="left">
  280. <view v-for="(date, timeIndex) in item.sellingStartTimeList" :key="timeIndex" class="item_weekTime">
  281. <span>{{ date[0] }}</span>
  282. <!-- <span>{{ date[0] ? date[0] + '-' + date[1] : '' }}</span> -->
  283. <span v-show="date[0]" style="color: #dd524d;" @click="deleteWeekTime(item, timeIndex)">
  284. <u-icon name="minus-circle-fill" style="margin-left: 17rpx;"></u-icon>
  285. </span>
  286. </view>
  287. </uni-td>
  288. <uni-td width="100rpx" align="center">
  289. <view class="uni-group">
  290. <span style="color: #007aff;" @click="addWeekTime(item)"><u-icon
  291. name="plus-circle-fill"></u-icon></span>
  292. </view>
  293. </uni-td>
  294. </uni-tr>
  295. </uni-table>
  296. <view>
  297. </view>
  298. </view>
  299. </view>
  300. <view class="item">
  301. <view class="label">
  302. 可用时间<span>*</span>
  303. </view>
  304. <view class="picker set">
  305. <view class="picker set inp" @click="setUsable" v-if="showSellDate == ''">
  306. <u-input placeholder="去设置" />
  307. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  308. </view>
  309. <view class="picker set inp" @click="setUsable" v-else>
  310. <span style="color: #333333;">{{ showSellDate }}</span>
  311. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  312. </view>
  313. </view>
  314. </view>
  315. <view class="item">
  316. <view class="label">
  317. 预约规则<span>*</span>
  318. </view>
  319. <view class="picker set">
  320. <u-checkbox v-model="makeChecked" style="margin-left:8rpx;" size="24"><span
  321. style="font-size: 26rpx;line-height: 28px;">用户需要提前预约</span></u-checkbox>
  322. </view>
  323. </view>
  324. <view class="item upload" style="border: none;">
  325. <view class="label" style="margin-bottom: 8rpx;">
  326. 服务说明<span>*</span>
  327. </view>
  328. <uni-data-checkbox multiple v-model="form.serviceDescription"
  329. :localdata="optionsDescription"></uni-data-checkbox>
  330. </view>
  331. <!-- <view class="form" style="margin-bottom: 24rpx;">
  332. <view class="titl ">
  333. 下单奖励
  334. </view>
  335. <view class="prompt">提示:金豆或积分余额不足时,将自动关闭奖励,不影响商品状态</view>
  336. <view class="item" style="border:none;margin-bottom:0">
  337. <view class="label">
  338. 金豆奖励
  339. </view>
  340. <view class="picker set">
  341. <u-switch v-model="jindouChecked" :disabled="tabIndex == 1" style="margin-left:8rpx;" size="28"
  342. @change="e => e == false ? form.goldAward = '' : ''"></u-switch>
  343. </view>
  344. </view>
  345. <view style="border:none;" v-if="jindouChecked">
  346. <view class="exchange-input">
  347. <input type="digit" v-model.number="form.goldAward"
  348. @input="e => form.goldAward = e.detail.value ? e.detail.value.replace(/[^\d]/g, '') : ''"
  349. placeholder="请输入金豆奖励数量" placeholder-class="input-placeholder" />
  350. <text class="exchange-all">个金豆</text>
  351. </view>
  352. </view>
  353. <view class="item" style="border:none;">
  354. <view class="label">
  355. 积分奖励
  356. </view>
  357. <view class="picker set">
  358. <u-switch v-model="jifenChecked" :disabled="tabIndex == 1" style="margin-left:8rpx;" size="28"
  359. @change="e => e == false ? form.integralAward = '' : ''"></u-switch>
  360. </view>
  361. </view>
  362. <view style="border:none;" v-if="jifenChecked">
  363. <view class="exchange-input">
  364. <input type="digit" v-model.number="form.integralAward"
  365. @input="e => form.integralAward = e.detail.value ? e.detail.value.replace(/[^\d]/g, '') : ''"
  366. placeholder="请输入积分奖励数量" placeholder-class="input-placeholder" />
  367. <text class="exchange-all">个积分</text>
  368. </view>
  369. </view>
  370. </view> -->
  371. <!-- <view class="form">
  372. <view class="titl ">
  373. 售卖/使用信息
  374. </view>
  375. <view class="item">
  376. <view class="label">
  377. 售卖时间<span>*</span>
  378. </view>
  379. <view class="picker set inp" @click="selectDate">
  380. <u-input :disabled="tabIndex == 1" placeholder="去设置" v-model="showDate" @click="selectDate" />
  381. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  382. </view>
  383. </view>
  384. <view class="item">
  385. <view class="label">
  386. 库存<span>*</span>
  387. </view>
  388. <view class="picker set">
  389. <u-input type="number" v-model="form.stockQuantity" placeholder="输入库存数量" />
  390. </view>
  391. </view>
  392. <view class="item">
  393. <view class="label">
  394. 退款规则<span>*</span>
  395. </view>
  396. <view class="picker set" @click="tabIndex == 0 ? isRefund = true : ''">
  397. <view class="" v-if="showRule" style="color: #333333;">
  398. {{ showRule }}
  399. </view>
  400. <view class="" v-else>
  401. 请选择
  402. <u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
  403. </view>
  404. </view>
  405. </view>
  406. <view class="item upload">
  407. <view class="label">
  408. 使用说明
  409. </view>
  410. <view class="textarea">
  411. <u-input v-model="form.instructions" :disabled="tabIndex == 1" type="textarea" placeholder="请输入"
  412. maxlength="500" />
  413. </view>
  414. <view class="num">
  415. <span v-if="form.instructions">{{ form.instructions.length > 0 ? form.instructions.length : '0'
  416. }}</span>/500
  417. </view>
  418. </view>
  419. </view> -->
  420. </view>
  421. </view>
  422. <view class="btn">
  423. <view class="next" @click="next" v-if="schedule == 1">
  424. 下一步
  425. </view>
  426. <view class="handle" v-else>
  427. <view class="back" @click="schedule -= 1">
  428. 上一步
  429. </view>
  430. <view class="submit" @click="submit">
  431. 提交审核
  432. </view>
  433. </view>
  434. </view>
  435. <rangTime ref="rangTime" :mode="mode" @onSubmit="onEndTimeChange" :title="timeTitle" />
  436. <rangTime ref="rangSaleTime" :mode="mode" @onSubmit="onSaleTimeChange" :title="timeTitle" />
  437. <rangTime ref="rangWeekTime" :mode="mode" @onSubmit="onWeekTimeChange" :title="timeTitle" />
  438. <!-- <refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel" @confirm="saveFound"
  439. @close="cutRule" /> -->
  440. <view class="popup" v-if="isSelectType">
  441. <view class="model">
  442. <view class="title">
  443. 商品品类
  444. <image src="/static/index/cut.png" mode="" @click="closePopup"></image>
  445. </view>
  446. <view class="tree">
  447. <view class="left">
  448. <view class="item" :class="currentLeft == index ? 'active' : ''" v-for="(item, index) in treeLeft"
  449. :key="item.id" @click="selectLeft(item, index)">
  450. {{ item.name }}
  451. </view>
  452. </view>
  453. <view class="left border">
  454. <view class="item" :class="currentCenter == index ? 'active' : ''" v-for="(item, index) in treeCenter"
  455. :key="item.id" @click="selectRight(item, index)">
  456. {{ item.name }}
  457. </view>
  458. </view>
  459. <view class="left">
  460. <view class="item" :class="currentRight == index ? 'active' : ''" v-for="(item, index) in treeRight"
  461. :key="item.id" @click="selectLast(item, index)">
  462. {{ item.name }}
  463. </view>
  464. </view>
  465. </view>
  466. <view class="sub">
  467. <view class="submit" @click="selectType">
  468. 确定
  469. </view>
  470. </view>
  471. </view>
  472. </view>
  473. <!-- 商品分组 -->
  474. <u-select v-model="showGroupPicker" mode="single-column" label-name="name" value-name="id" :list="groupOptions"
  475. @confirm="groupConfirm($event)" @cancel="showGroupPicker = false"></u-select>
  476. </view>
  477. </template>
  478. <script>
  479. import rangTime from '../../components/dengrq-datetime-picker/dateSelector/index.vue'
  480. import refund from '@/components/product/refund.vue'
  481. import configService from '../../common/service/config.service'
  482. import Editor from '@/uni_modules/sp-editor/components/sp-editor/sp-editor.vue';
  483. import {
  484. nextTick
  485. } from "vue"
  486. export default {
  487. components: {
  488. rangTime,
  489. refund,
  490. Editor
  491. },
  492. data() {
  493. return {
  494. toolbarConfig: {
  495. excludeKeys: ['header', 'lineHeight', 'letterSpacing', 'marginTop', 'export', 'marginBottom', 'fontFamily', 'indentDec', 'indentInc', 'scriptSub', 'scriptSuper', 'direction', 'video', 'listCheck', 'divider', 'removeFormat'],
  496. },
  497. video: '',
  498. tabIndex: '0',
  499. mode: 5,
  500. allChecked: false,
  501. form: {
  502. instructions: '',
  503. preBook: 0,
  504. merchantId: null,
  505. groupingId: '',
  506. groupingName: '',
  507. searchKeywords: '',
  508. saleTime: '',
  509. virtualSales: '',
  510. sellingTimeType: '',
  511. serviceDescription: [],
  512. richText: '',
  513. // 为"每天"选项添加单独的时间段数组
  514. sellingDay: [],
  515. localProductSellingWeeks: []
  516. // categoryId:'',
  517. // productName: '',
  518. // productImage: '',
  519. // checked: null,
  520. // num: 0,
  521. // refundLabel:null,
  522. // refundConfirm:null
  523. },
  524. optionsSaleTime: [
  525. {
  526. text: '不限制',
  527. value: '1'
  528. },
  529. {
  530. text: '每天',
  531. value: '2'
  532. }
  533. ],
  534. optionsDescription: [
  535. {
  536. text: '说明1',
  537. value: '说明1'
  538. },
  539. {
  540. text: '说明2',
  541. value: '说明2'
  542. }
  543. ],
  544. fmImageList: [], //封面图回显
  545. xqImage: [], //详情图回显
  546. showRule: '', //显示退款规则文字
  547. action: configService.apiUrl + '/sys/common/upload', //图片上传地址
  548. // action: 'http://192.168.0.36:8080/jeecg-boot/sys/common/upload', //图片上传地址
  549. schedule: 1, //进度
  550. fileList: [],
  551. selectedTime: null,
  552. isSelectDate: false,
  553. isRefund: false,
  554. isSelectType: false,
  555. treeLeft: [], //一级列表
  556. treeCenter: [], //二级列表
  557. treeRight: [], //三级列表
  558. currentLeft: 0, //一级选中
  559. currentCenter: 0, //二级选中
  560. currentRight: 0, //三级选中
  561. productType: [], //选中的商品分类id
  562. selectTypeList: [], //选中的商品分类名称
  563. showText: '',
  564. showDate: '',
  565. showSellDate: '',
  566. makeChecked: false,
  567. // imageHttp: 'http://192.168.0.36:8080/jeecg-boot/', //上传图片前缀+
  568. imageHttp: configService.apiUrl + '/', //上传图片前缀+
  569. productId: '',
  570. jindouChecked: false,
  571. jifenChecked: false,
  572. selectVaule: 0, //钣金喷漆选择
  573. all: false, //是否全选
  574. reverse: false, //是否反选
  575. selectProductSunItem: [],
  576. timeTitle: '选择售卖时间',
  577. // 商品分组列表
  578. showGroupPicker: false,
  579. groupOptions: [],
  580. // 为"每周"选项添加单独的时间段数组
  581. localProductSellingWeeks: [
  582. {
  583. weekDay: '周一',
  584. sellingStartTimeList: [],
  585. checked: false
  586. },
  587. {
  588. weekDay: '周二',
  589. sellingStartTimeList: [],
  590. checked: false
  591. },
  592. {
  593. weekDay: '周三',
  594. sellingStartTimeList: [],
  595. checked: false
  596. },
  597. {
  598. weekDay: '周四',
  599. sellingStartTimeList: [],
  600. checked: false
  601. },
  602. {
  603. weekDay: '周五',
  604. sellingStartTimeList: [],
  605. checked: false
  606. },
  607. {
  608. weekDay: '周六',
  609. sellingStartTimeList: [],
  610. checked: false
  611. },
  612. {
  613. weekDay: '周日',
  614. sellingStartTimeList: [],
  615. checked: false
  616. }
  617. ]
  618. }
  619. },
  620. methods: {
  621. //全选
  622. allSelect() {
  623. this.all = true
  624. this.reverse = false
  625. this.form.specItems.forEach(item => {
  626. item.replaced = true
  627. })
  628. },
  629. //反选
  630. reverseSelsct() {
  631. this.reverse = true
  632. this.all = false
  633. this.form.specItems.forEach(item => {
  634. item.replaced = !item.replaced
  635. })
  636. },
  637. //选中
  638. select(item) {
  639. item.replaced = !item.replaced
  640. // const index = this.form.specItems.findIndex(i => i.id === item.id);
  641. // if (index !== -1) {
  642. // this.form.specItems.splice(index, 1, {
  643. // ...item,
  644. // replaced: !item.replaced
  645. // });
  646. // }
  647. },
  648. // 上传封面图成功回调
  649. handleSuccess(res, index, lists) {
  650. try {
  651. // 更新fmImageList为最新的列表(由u-upload组件维护)
  652. this.fmImageList = lists;
  653. // 处理图片列表,生成URL字符串
  654. let temp = [];
  655. lists.forEach(item => {
  656. if (item.response && item.response.message) {
  657. temp.push(this.imageHttp + item.response.message);
  658. } else if (item.url) {
  659. // 处理已存在的图片
  660. temp.push(item.url);
  661. }
  662. });
  663. // 将多张图片URL以逗号分隔拼接
  664. this.form.productImage = temp.join(',');
  665. } catch (error) {
  666. uni.showToast({
  667. title: '封面图更新失败',
  668. icon: 'none'
  669. });
  670. }
  671. },
  672. // 移除封面图文件回调
  673. handleRemove(index, lists) {
  674. try {
  675. // 更新fmImageList为最新的列表(由u-upload组件维护)
  676. this.fmImageList = lists;
  677. // 处理图片列表,生成URL字符串
  678. let temp = [];
  679. lists.forEach(item => {
  680. if (item.response && item.response.message) {
  681. temp.push(this.imageHttp + item.response.message);
  682. } else if (item.url) {
  683. // 处理已存在的图片
  684. temp.push(item.url);
  685. }
  686. });
  687. // 将多张图片URL以逗号分隔拼接
  688. this.form.productImage = temp.join(',');
  689. } catch (error) {
  690. uni.showToast({
  691. title: '封面图移除失败',
  692. icon: 'none'
  693. });
  694. }
  695. },
  696. //上传详情图
  697. detailsSuccess(res, index, lists) {
  698. console.log(lists)
  699. this.processImageList(lists);
  700. this.xqImage = lists
  701. },
  702. detailsRemove(index, lists) {
  703. this.xqImage = lists
  704. this.processImageList(lists);
  705. },
  706. // 处理图片列表,生成URL字符串
  707. processImageList(lists) {
  708. let temp = [];
  709. lists.forEach(item => {
  710. if (item.response && item.response.message) {
  711. temp.push(this.imageHttp + item.response.message);
  712. } else if (item.url) {
  713. // 处理已存在的图片
  714. temp.push(item.url);
  715. }
  716. });
  717. this.form.detailImages = temp.join(',');
  718. console.log('当前图片URL字符串:', this.form.detailImages);
  719. },
  720. //下一步
  721. next() {
  722. let temp = []
  723. if (this.form.specItems) {
  724. this.form.specItems.forEach(item => {
  725. // item.replaced = true
  726. if (item.replaced) {
  727. this.selectProductSunItem.push(item)
  728. }
  729. })
  730. // this.form.specItems = temp
  731. }
  732. //基础信息必填提示
  733. if (!this.form.productName) {
  734. uni.showToast({
  735. title: '请输入商品名称',
  736. icon: 'none'
  737. });
  738. return
  739. }
  740. if (!this.form.categoryId) {
  741. uni.showToast({
  742. title: '请选择商品分类',
  743. icon: 'none'
  744. });
  745. return
  746. }
  747. if (this.tabIndex == '0' && !this.form.groupingId) {
  748. uni.showToast({
  749. title: '请选择商品分组',
  750. icon: 'none'
  751. });
  752. return
  753. }
  754. if (!this.form.productImage) {
  755. uni.showToast({
  756. title: '请上传商品封面图',
  757. icon: 'none'
  758. });
  759. return
  760. }
  761. if (this.tabIndex == '0' && !this.form.richText) {
  762. uni.showToast({
  763. title: '请完善商品详情页',
  764. icon: 'none'
  765. });
  766. return
  767. }
  768. if (this.tabIndex == '0' && !this.form.searchKeywords) {
  769. uni.showToast({
  770. title: '请输入搜索关键字',
  771. icon: 'none'
  772. });
  773. return
  774. }
  775. // if (!this.form.price && !this.form.categoryId == '1945013773786701826') {
  776. // uni.showToast({
  777. // title: '请输入商品原价',
  778. // icon: 'none'
  779. // });
  780. // return
  781. // }
  782. // if (!this.form.soldPrice && !this.form.categoryId == '1945013773786701826') {
  783. // uni.showToast({
  784. // title: '请输入商品售价',
  785. // icon: 'none'
  786. // });
  787. // return
  788. // } else if (this.form.categoryId == '1945013773786701826' && this.selectProductSunItem.length == 0) {
  789. // uni.showToast({
  790. // title: '请选择最少一个配置',
  791. // icon: 'none'
  792. // });
  793. // } else {
  794. // this.schedule += 1
  795. // }
  796. this.schedule += 1
  797. },
  798. // 跳转至组合商品页
  799. goGroup() {
  800. // if(this.tabIndex==0){
  801. uni.navigateTo({
  802. url: '/pages/product/group'
  803. })
  804. // }
  805. },
  806. //返回
  807. back() {
  808. uni.navigateTo({
  809. url: '/pages/product/index'
  810. })
  811. },
  812. // 处理 confirm 事件,接收子组件传递的时间段数据
  813. handleConfirm(time) {
  814. this.selectedTime = time; // 保存时间段数据
  815. this.isSelectDate = false
  816. },
  817. //隐藏弹窗
  818. closeSelectDate() {
  819. this.isSelectDate = false
  820. },
  821. //跳转至可用时间
  822. setUsable() {
  823. uni.navigateTo({
  824. url: '/pages/product/usable'
  825. })
  826. },
  827. // 更新时间
  828. updateRangeTime() {
  829. uni.getStorage({
  830. key: 'smdate',
  831. success: (res) => {
  832. if (res.data.useType == 2) {
  833. this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
  834. this.form.availableStartDate = res.data.availableStartDate
  835. this.form.availableEndDate = res.data.availableEndDate
  836. this.form.expirationDays = null
  837. this.form.useType = 2
  838. } else if (res.data.useType == 1) {
  839. this.form.expirationDays = res.data.expirationDays
  840. this.form.availableEndDate = null
  841. this.form.availableStartDate = null
  842. this.form.useType = 1
  843. this.$nextTick(() => {
  844. this.showSellDate = res.data.expirationDays + '天后失效'
  845. });
  846. } else if (res.data.useType == 3) {
  847. this.form.useType = 3
  848. this.showSellDate = '长期有效'
  849. }
  850. }
  851. })
  852. },
  853. // 校验商品市场价必须大于商品售价
  854. checkPriceAndSoldPrice(field) {
  855. if ((field == 'price' && this.form.soldPrice) || (field == 'soldPrice' && this.form.price)) {
  856. if (this.form.soldPrice <= this.form.price) {
  857. uni.showToast({
  858. title: '商品市场价必须大于商品售价',
  859. icon: 'none',
  860. duration: 2000
  861. });
  862. this.$nextTick(() => {
  863. this.form[field] = '';
  864. });
  865. }
  866. }
  867. },
  868. // 保存退款规则
  869. saveFound(rules) {
  870. this.form.refundConfirm = rules.refundConfirm.refundConfirm
  871. this.form.refundLabel = rules.refundLabel.refundLabel
  872. let value1 = []
  873. value1.push(rules.refundConfirm.name, rules.refundLabel.name)
  874. this.showRule = value1.join("·")
  875. // this.selectedRules = rules;
  876. this.isRefund = false
  877. },
  878. cutRule() {
  879. this.isRefund = false
  880. },
  881. //获取商品分类一级列表
  882. getLeftTree() {
  883. this.$http.get("/sys/category/childList?pid=" + '1889836358116098050', {}).then(res => {
  884. if (res.data.code == 0) {
  885. this.treeLeft = res.data.result
  886. if (this.treeLeft[0]) {
  887. this.getCenterTree(this.treeLeft[0].id)
  888. }
  889. }
  890. })
  891. },
  892. //获取商品分类二级列表
  893. getCenterTree(id) {
  894. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  895. if (res.data.code == 0) {
  896. this.treeCenter = res.data.result
  897. if (this.treeCenter[0]) {
  898. // this.getRightTree(this.treeCenter[0].id)
  899. }
  900. }
  901. })
  902. },
  903. //获取商品分类三级列表
  904. getRightTree(id) {
  905. this.$http.get("/sys/category/childList?pid=" + id, {}).then(res => {
  906. if (res.data.code == 0) {
  907. this.treeRight = res.data.result
  908. }
  909. })
  910. },
  911. selectProductType() {
  912. if (this.tabIndex == '0') {
  913. this.isSelectType = true
  914. this.showText = ''
  915. this.productType = []
  916. this.selectTypeList = []
  917. this.currentLeft = null
  918. this.currentCenter = null
  919. this.currentRight = null
  920. }
  921. },
  922. selectGrouping() {
  923. if (this.tabIndex == '0') {
  924. this.showGroupPicker = true
  925. }
  926. },
  927. //选中一级
  928. selectLeft(item, index) {
  929. this.currentLeft = index
  930. this.currentCenter = null
  931. this.currentRight = null
  932. this.treeCenter = []
  933. this.treeRight = []
  934. this.productType = []
  935. this.selectTypeList = []
  936. this.productType.push(item.id)
  937. this.selectTypeList.push(item.name)
  938. this.getCenterTree(item.id)
  939. },
  940. //选中二级
  941. selectRight(item, index) {
  942. this.getRightTree(this.treeCenter[0].id)
  943. this.currentCenter = index
  944. this.currentRight = null
  945. if (this.selectTypeList.length >= 2) {
  946. this.productType.splice(1, 2)
  947. this.selectTypeList.splice(1, 2)
  948. }
  949. this.productType.push(item.id)
  950. this.selectTypeList.push(item.name)
  951. this.getRightTree(item.id)
  952. },
  953. //选中三级
  954. selectLast(item, index) {
  955. if (this.selectTypeList.length >= 3) {
  956. this.productType.splice(2, 1)
  957. this.selectTypeList.splice(2, 1)
  958. }
  959. this.productType.push(item.id)
  960. this.selectTypeList.push(item.name)
  961. this.currentRight = index
  962. },
  963. //确定分类
  964. selectType() {
  965. this.isSelectType = false
  966. this.form.categoryId = this.productType.join(',')
  967. this.showText = this.selectTypeList.join('·')
  968. },
  969. //关闭选择分类弹窗
  970. closePopup() {
  971. this.isSelectType = false
  972. },
  973. //获取商品分组列表
  974. getProductGroup() {
  975. this.$http.get("/localProductGrouping/localProductGrouping/getAppList?sourceType=1").then(res => {
  976. if (res.data.success) {
  977. this.groupOptions = res.data.result || []
  978. }
  979. })
  980. },
  981. // 确定分组
  982. groupConfirm(e) {
  983. this.form.groupingId = e[0].value
  984. this.form.groupingName = e[0].label
  985. this.showGroupPicker = false;
  986. },
  987. selectDate() {
  988. // this.isSelectDate = true
  989. this.$refs.rangTime.open()
  990. },
  991. onEndTimeChange(val) {
  992. this.form.saleStartDate = val.startDate
  993. this.form.saleEndDate = val.endDate
  994. this.showDate = val.startDate + '-' + val.endDate
  995. this.$forceUpdate(); // 强制刷新视图
  996. },
  997. // 选择售卖时间
  998. selectSaleDate() {
  999. this.$refs.rangSaleTime.open()
  1000. },
  1001. onSaleTimeChange(val) {
  1002. if (val && val.startDate && val.endDate) {
  1003. // const timeRange = [val.startDate, val.endDate];
  1004. // this.form.sellingDay.push(timeRange)
  1005. const timeRange = `${val.startDate}-${val.endDate}`;
  1006. this.form.sellingDay.push([timeRange])
  1007. }
  1008. this.$forceUpdate(); // 强制刷新视图
  1009. },
  1010. deleteTime(index) {
  1011. this.form.sellingDay.splice(index, 1);
  1012. this.$forceUpdate(); // 强制刷新视图
  1013. },
  1014. // 选择每周售卖时间
  1015. // 全选/全不选处理
  1016. handleAllCheckChange(e) {
  1017. const checked = e.value;
  1018. if (!checked) {
  1019. // 显示确认提示框
  1020. uni.showModal({
  1021. title: '提示',
  1022. content: '取消全选将清空每周已添加的时间段,是否继续',
  1023. success: (res) => {
  1024. if (res.confirm) {
  1025. // 用户确认取消全选,清空时间段数据
  1026. this.allChecked = checked;
  1027. this.form.localProductSellingWeeks.forEach(item => {
  1028. item.checked = checked;
  1029. // 当取消全选时,清空所有时间段
  1030. if (!checked) {
  1031. item.sellingStartTimeList = [];
  1032. }
  1033. });
  1034. } else {
  1035. this.allChecked = true;
  1036. }
  1037. }
  1038. });
  1039. } else {
  1040. this.allChecked = checked;
  1041. this.form.localProductSellingWeeks.forEach(item => {
  1042. item.checked = checked;
  1043. // 当取消全选时,清空所有时间段
  1044. if (!checked) {
  1045. item.sellingStartTimeList = [];
  1046. }
  1047. });
  1048. }
  1049. },
  1050. // 单个复选框变化处理
  1051. handleItemCheckChange(e, row) {
  1052. // 获取最新的复选框状态
  1053. const isChecked = e.value;
  1054. // 判断如果checked状态是false,清空该行的sellingStartTimeList日期
  1055. if (!isChecked) {
  1056. // 确保sellingStartTimeList是响应式的
  1057. if (!row.sellingStartTimeList) {
  1058. this.$set(row, 'sellingStartTimeList', []);
  1059. } else {
  1060. // 清空数组,保持引用
  1061. row.sellingStartTimeList.splice(0, row.sellingStartTimeList.length);
  1062. }
  1063. }
  1064. },
  1065. // 每周添加时间
  1066. addWeekTime(item) {
  1067. // 判断如果当前行的checked状态是false,提示用户先勾选
  1068. if (!item.checked) {
  1069. uni.showToast({
  1070. title: '请先勾选当前行',
  1071. icon: 'none'
  1072. });
  1073. return; // 终止后续操作
  1074. }
  1075. this.addWeekDay = item.weekDay
  1076. this.$refs.rangWeekTime.open()
  1077. },
  1078. // 每周删除时间
  1079. deleteWeekTime(item, timeIndex) {
  1080. // 使用splice删除指定索引的时间段
  1081. item.sellingStartTimeList.splice(timeIndex, 1);
  1082. this.$forceUpdate(); // 强制刷新视图
  1083. },
  1084. onWeekTimeChange(val) {
  1085. if (val && val.startDate && val.endDate) {
  1086. const timeRange = `${val.startDate}-${val.endDate}`;
  1087. // const timeRange = [val.startDate, val.endDate];
  1088. this.form.localProductSellingWeeks.forEach(item => {
  1089. if (item.weekDay == this.addWeekDay) {
  1090. item.sellingStartTimeList.push([timeRange])
  1091. }
  1092. })
  1093. }
  1094. this.$forceUpdate(); // 强制刷新视图
  1095. },
  1096. //提交审核
  1097. submit() {
  1098. console.log(this.form)
  1099. this.form.specItems = this.selectProductSunItem
  1100. this.form.isApp = '1'
  1101. this.makeChecked ? this.form.preBook = 1 : this.form.preBook = 0
  1102. // if (!this.form.saleStartDate) {
  1103. // uni.showToast({
  1104. // title: '请设置售卖时间',
  1105. // icon: 'none'
  1106. // });
  1107. // return
  1108. // } else if (!this.form.stockQuantity) {
  1109. // uni.showToast({
  1110. // title: '请输入商品库存',
  1111. // icon: 'none'
  1112. // });
  1113. // return
  1114. // } else if (this.tabIndex != 1 && (this.form.refundConfirm == null || this.form.refundLabel == null)) {
  1115. // uni.showToast({
  1116. // title: '请选择退款标签',
  1117. // icon: 'none'
  1118. // });
  1119. // return
  1120. // }
  1121. if (!this.form.price) {
  1122. uni.showToast({
  1123. title: '请输入商品售价',
  1124. icon: 'none'
  1125. });
  1126. return
  1127. }
  1128. if (!this.form.soldPrice) {
  1129. uni.showToast({
  1130. title: '请输入商品市场价',
  1131. icon: 'none'
  1132. });
  1133. return
  1134. }
  1135. if (this.form.soldPrice <= this.form.price) {
  1136. uni.showToast({
  1137. title: '商品市场价必须大于商品售价',
  1138. icon: 'none'
  1139. });
  1140. return
  1141. }
  1142. if (this.tabIndex == '1' && !this.form.sellingTimeType) {
  1143. uni.showToast({
  1144. title: '请选择售卖时间',
  1145. icon: 'none'
  1146. });
  1147. return
  1148. }
  1149. if (this.tabIndex == '1' && this.form.sellingTimeType == '2' && !this.form.sellingDay.length) {
  1150. uni.showToast({
  1151. title: '请添加售卖时间段',
  1152. icon: 'none'
  1153. });
  1154. return
  1155. }
  1156. if (!this.form.availableEndDate && !this.form.expirationDays) {
  1157. uni.showToast({
  1158. title: '请选择可用时间',
  1159. icon: 'none'
  1160. });
  1161. return
  1162. }
  1163. if (this.form.serviceDescription.length == 0) {
  1164. uni.showToast({
  1165. title: '请选择服务说明',
  1166. icon: 'none'
  1167. });
  1168. return
  1169. } else {
  1170. if (this.form.sellingTimeType == '3') {
  1171. this.form.sellingDay = []
  1172. } else if (this.form.sellingTimeType == '2') {
  1173. this.form.localProductSellingWeeks = []
  1174. }
  1175. if (this.productId == '') {
  1176. this.$http.post("/app/product/add", this.form).then(res => {
  1177. if (res.data.code == 200) {
  1178. uni.showToast({
  1179. title: '添加成功',
  1180. icon: 'none'
  1181. });
  1182. this.back()
  1183. uni.removeStorage({
  1184. key: 'smdate',
  1185. });
  1186. uni.removeStorage({
  1187. key: 'group',
  1188. });
  1189. } else {
  1190. uni.showToast({
  1191. title: res.data.message,
  1192. icon: 'none'
  1193. });
  1194. }
  1195. })
  1196. } else {
  1197. this.form.productId = this.productId
  1198. console.log(this.formState);
  1199. this.$http.post("/app/product/edit", this.form).then(res => {
  1200. if (res.data.code == 200) {
  1201. uni.showToast({
  1202. title: '编辑成功',
  1203. icon: 'none'
  1204. });
  1205. this.back()
  1206. } else {
  1207. uni.showToast({
  1208. icon: 'none',
  1209. title: res.data.message
  1210. })
  1211. }
  1212. uni.removeStorage({
  1213. key: 'smdate',
  1214. });
  1215. uni.removeStorage({
  1216. key: 'group',
  1217. });
  1218. })
  1219. }
  1220. }
  1221. },
  1222. //回显数据
  1223. getForm() {
  1224. this.$http.post("/app/product/queryByIdNew", {
  1225. id: this.productId,
  1226. isApp: '1'
  1227. }).then(res => {
  1228. if (res.data.code == 200) {
  1229. this.form = res.data.result
  1230. this.jifenChecked = res.data.result.integralAward ? true : false
  1231. this.jindouChecked = res.data.result.goldAward ? true : false
  1232. this.showText = res.data.result.productCategory
  1233. // 处理封面图,支持多张图片
  1234. if (res.data.result.productImage) {
  1235. let productImages = res.data.result.productImage.split(',');
  1236. productImages.forEach(imageUrl => {
  1237. if (imageUrl.trim()) { // 过滤空字符串
  1238. this.fmImageList.push({
  1239. url: imageUrl
  1240. });
  1241. }
  1242. });
  1243. }
  1244. if (res.data.result.detailImages) {
  1245. let xqtemp = []
  1246. xqtemp = res.data.result.detailImages.split(',')
  1247. xqtemp.map(item => {
  1248. this.xqImage.push({
  1249. url: item
  1250. })
  1251. })
  1252. console.log(this.xqImage)
  1253. }
  1254. // this.showDate = res.data.result.saleStartDate.slice(0, 10) + '-' + res.data.result.saleEndDate.slice(0,
  1255. // 10)
  1256. if (res.data.result.useType == 2) {
  1257. this.showSellDate = res.data.result.availableStartDate.slice(0, 10) + '-' + res.data.result
  1258. .availableEndDate.slice(0, 10)
  1259. } else if (res.data.result.useType == 1) {
  1260. this.showSellDate = res.data.result.expirationDays + '天后失效'
  1261. } else if (res.data.result.useType == 3) {
  1262. this.showSellDate = '长期有效'
  1263. }
  1264. res.data.result.preBook == 0 ? this.makeChecked = false : this.makeChecked = true
  1265. if (res.data.result.refundLabelName && res.data.result.refundConfirmName) {
  1266. this.showRule = res.data.result.refundLabelName + '·' + res.data.result.refundConfirmName
  1267. }
  1268. // 兼容旧数据
  1269. this.video = res.data.result.video || ''
  1270. if (!res.data.result.sellingDay) {
  1271. this.form.sellingDay = []
  1272. }
  1273. if (!res.data.result.localProductSellingWeeks) {
  1274. this.form.localProductSellingWeeks = this.localProductSellingWeeks
  1275. }
  1276. if (!res.data.result.serviceDescription) {
  1277. this.form.serviceDescription = []
  1278. }
  1279. // 初始化编辑器内容
  1280. if (res.data.result.richText) {
  1281. this.form.richText = res.data.result.richText || ''
  1282. this.editorCtx.setContents({
  1283. html: this.form.richText
  1284. })
  1285. }
  1286. uni.setStorage({
  1287. key: 'group',
  1288. data: res.data.result.productGroups
  1289. })
  1290. }
  1291. })
  1292. },
  1293. delectVideo() {
  1294. uni.showModal({
  1295. title: "提示",
  1296. content: "是否要删除此视频",
  1297. success: (res) => {
  1298. if (res.confirm) {
  1299. this.video = ''
  1300. }
  1301. }
  1302. })
  1303. },
  1304. chooseVideo() {
  1305. // 上传视频
  1306. console.log('上传视频')
  1307. uni.chooseVideo({
  1308. sourceType: ['camera', 'album'],
  1309. success: (res) => {
  1310. this.video = res.tempFilePath;
  1311. this.form.video = res.tempFilePath;
  1312. }
  1313. })
  1314. },
  1315. // 编辑器初始化完成时触发
  1316. onEditorInit(editorCtx, editorId) {
  1317. this.editorCtx = editorCtx // 保存编辑器上下文
  1318. this.editorId = editorId // 保存编辑器ID
  1319. console.log('编辑器初始化完成')
  1320. },
  1321. // 实时获取富文本内容
  1322. onEditorInput(e) {
  1323. this.form.richText = e.html
  1324. },
  1325. // 处理编辑器图片上传
  1326. handleEditorImageUpload(tempFiles, editorCtx, editorId) {
  1327. const file = tempFiles[0]
  1328. const uploadTask = uni.uploadFile({
  1329. url: configService.apiUrl + '/sys/common/upload', // 上传接口地址
  1330. filePath: file.path,
  1331. name: 'file', // 服务器接收的字段名
  1332. success: (res) => {
  1333. try {
  1334. const data = JSON.parse(res.data)
  1335. if (data.message) {
  1336. // 假设服务器返回的图片URL在data.url字段
  1337. const imageUrl = this.imageHttp + data.message
  1338. // 插入图片到编辑器
  1339. editorCtx.insertImage({
  1340. src: imageUrl,
  1341. alt: '图片',
  1342. success: function () {
  1343. console.log('图片插入成功')
  1344. }
  1345. })
  1346. } else {
  1347. uni.showToast({
  1348. title: '图片上传失败',
  1349. icon: 'none'
  1350. })
  1351. }
  1352. } catch (e) {
  1353. uni.showToast({
  1354. title: '图片上传失败',
  1355. icon: 'none'
  1356. })
  1357. }
  1358. },
  1359. fail: (err) => {
  1360. console.error('图片上传失败', err)
  1361. uni.showToast({
  1362. title: '图片上传失败',
  1363. icon: 'none'
  1364. })
  1365. }
  1366. })
  1367. }
  1368. },
  1369. mounted() {
  1370. this.form.localProductSellingWeeks = this.localProductSellingWeeks
  1371. this.getProductGroup()
  1372. this.getLeftTree()
  1373. this.getForm()
  1374. this.updateRangeTime()
  1375. },
  1376. onLoad(options) {
  1377. if (options.productId) {
  1378. this.productId = options.productId
  1379. }
  1380. if (options.tabIndex) {
  1381. this.tabIndex = options.tabIndex
  1382. }
  1383. },
  1384. onShow() {
  1385. let that = this
  1386. uni.getStorage({
  1387. key: 'login_user_info',
  1388. success: function (res) {
  1389. that.form.merchantId = res.data.merchantId
  1390. }
  1391. })
  1392. that.updateRangeTime()
  1393. uni.getStorage({
  1394. key: 'group',
  1395. success: function (res) {
  1396. that.form.productGroups = res.data
  1397. }
  1398. })
  1399. }
  1400. }
  1401. </script>
  1402. <style lang="scss" scoped>
  1403. .creat {
  1404. width: 100vw;
  1405. height: 100vh;
  1406. background: #F7F8FC;
  1407. display: flex;
  1408. flex-direction: column;
  1409. justify-content: space-between;
  1410. /*#ifdef APP-PLUS*/
  1411. .top {
  1412. width: 100%;
  1413. height: var(--status-bar-height);
  1414. background-color: #fff;
  1415. }
  1416. /*#endif*/
  1417. .head {
  1418. width: 100%;
  1419. height: 112rpx;
  1420. padding: 32rpx 24rpx;
  1421. display: flex;
  1422. align-items: center;
  1423. background-color: #fff;
  1424. position: relative;
  1425. .cuIcon-back {
  1426. font-size: 40rpx;
  1427. margin-right: 40rpx;
  1428. }
  1429. .case {
  1430. font-size: 36rpx;
  1431. font-weight: 600;
  1432. position: absolute;
  1433. top: 50%;
  1434. left: 50%;
  1435. transform: translate(-50%, -50%);
  1436. }
  1437. .step {
  1438. position: absolute;
  1439. right: 20rpx;
  1440. }
  1441. }
  1442. .content {
  1443. width: 100%;
  1444. flex: 1;
  1445. padding: 24rpx;
  1446. overflow-y: auto;
  1447. .prompt {
  1448. font-weight: 400;
  1449. font-size: 28rpx;
  1450. color: #999999;
  1451. // padding: 10rpx 0;
  1452. margin-bottom: 18rpx;
  1453. }
  1454. .titl {
  1455. width: 100%;
  1456. // height: 60rpx;
  1457. font-weight: 600;
  1458. font-size: 32rpx;
  1459. color: #333333;
  1460. margin-bottom: 16rpx;
  1461. }
  1462. .form {
  1463. background-color: #fff;
  1464. padding: 16rpx;
  1465. border-radius: 16rpx;
  1466. .item {
  1467. width: 100%;
  1468. height: 58rpx;
  1469. border-bottom: 1px solid #EEEEEE;
  1470. display: flex;
  1471. // align-items: center;
  1472. padding-bottom: 16rpx;
  1473. margin-bottom: 16rpx;
  1474. .label {
  1475. margin-right: 20rpx;
  1476. font-weight: 600;
  1477. font-size: 28rpx;
  1478. min-width: 126rpx;
  1479. span {
  1480. color: red;
  1481. }
  1482. }
  1483. .picker {
  1484. flex: 1;
  1485. display: flex;
  1486. align-items: center;
  1487. justify-content: space-between;
  1488. font-size: 28rpx;
  1489. color: #999999;
  1490. }
  1491. .set {
  1492. display: flex;
  1493. justify-content: flex-end;
  1494. ::v-deep.u-input {
  1495. text-align: right !important;
  1496. }
  1497. }
  1498. }
  1499. .spray {
  1500. .label {
  1501. height: 57rpx;
  1502. margin-right: 20rpx;
  1503. font-weight: 600;
  1504. font-size: 28rpx;
  1505. min-width: 126rpx;
  1506. margin-bottom: 16rpx;
  1507. .change {
  1508. display: flex;
  1509. align-items: center;
  1510. font-weight: 400;
  1511. span {
  1512. display: flex;
  1513. align-items: center;
  1514. margin-left: 30rpx;
  1515. }
  1516. image {
  1517. width: 36rpx;
  1518. height: 36rpx;
  1519. font-size: 28rpx;
  1520. margin-right: 4rpx;
  1521. }
  1522. }
  1523. }
  1524. .spray_items {
  1525. .spra {
  1526. height: 106rpx;
  1527. margin-bottom: 32rpx;
  1528. display: flex;
  1529. align-items: start;
  1530. .square {
  1531. margin-right: 12rpx;
  1532. image {
  1533. width: 30rpx;
  1534. height: 40rpx;
  1535. }
  1536. }
  1537. .name {
  1538. display: flex;
  1539. font-size: 28rpx;
  1540. margin-bottom: 16rpx;
  1541. }
  1542. .price {
  1543. height: 49rpx;
  1544. display: flex;
  1545. justify-content: space-between;
  1546. .option {
  1547. display: flex;
  1548. align-items: center;
  1549. font-size: 26rpx;
  1550. color: #666666;
  1551. input {
  1552. height: 49rpx;
  1553. width: 160rpx;
  1554. background: #F7F8FC;
  1555. border-radius: 4rpx;
  1556. margin-left: 10rpx;
  1557. text-align: center;
  1558. font-size: 26rpx;
  1559. color: #666666;
  1560. }
  1561. }
  1562. }
  1563. }
  1564. }
  1565. }
  1566. .upload {
  1567. display: block;
  1568. height: auto;
  1569. .tips {
  1570. font-size: 20rpx;
  1571. color: #999999;
  1572. margin-bottom: 16rpx;
  1573. margin-top: 10rpx;
  1574. }
  1575. }
  1576. .textarea {
  1577. width: 100%;
  1578. height: 196rpx;
  1579. background: #F7F8FC;
  1580. border-radius: 4rpx;
  1581. padding: 12rpx 16rpx;
  1582. font-size: 26rpx;
  1583. margin-top: 12rpx;
  1584. }
  1585. .num {
  1586. width: 100%;
  1587. text-align: right;
  1588. font-size: 24rpx;
  1589. color: #999999;
  1590. margin-top: 6rpx;
  1591. }
  1592. }
  1593. }
  1594. .btn {
  1595. width: 100%;
  1596. height: 112rpx;
  1597. background-color: #fff;
  1598. display: flex;
  1599. justify-content: center;
  1600. align-items: center;
  1601. .next {
  1602. width: 672rpx;
  1603. height: 76rpx;
  1604. border-radius: 54rpx;
  1605. border: 1px solid #449AFF;
  1606. margin: 0 auto;
  1607. display: flex;
  1608. justify-content: center;
  1609. align-items: center;
  1610. font-size: 28rpx;
  1611. color: #449AFF;
  1612. }
  1613. .handle {
  1614. width: 100%;
  1615. display: flex;
  1616. justify-content: space-around;
  1617. .back {
  1618. width: 205rpx;
  1619. height: 76rpx;
  1620. border-radius: 54rpx;
  1621. border: 1px solid #449AFF;
  1622. display: flex;
  1623. align-items: center;
  1624. justify-content: center;
  1625. font-size: 28rpx;
  1626. color: #449AFF;
  1627. }
  1628. .submit {
  1629. width: 443rpx;
  1630. height: 76rpx;
  1631. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1632. border-radius: 53rpx;
  1633. display: flex;
  1634. align-items: center;
  1635. justify-content: center;
  1636. font-size: 28rpx;
  1637. color: #FFFFFF;
  1638. }
  1639. }
  1640. }
  1641. .popup {
  1642. width: 100vw;
  1643. height: 100vh;
  1644. position: fixed;
  1645. top: 0;
  1646. left: 0;
  1647. background: rgba(0, 0, 0, 0.4);
  1648. display: flex;
  1649. align-items: flex-end;
  1650. z-index: 99;
  1651. .model {
  1652. width: 100%;
  1653. background-color: #fff;
  1654. border-radius: 20rpx 20rpx 0rpx 0rpx;
  1655. padding: 0rpx 24rpx;
  1656. padding-bottom: 20rpx;
  1657. .title {
  1658. width: 100%;
  1659. height: 86rpx;
  1660. display: flex;
  1661. align-items: center;
  1662. justify-content: center;
  1663. border-bottom: 1px solid #EEEEEE;
  1664. position: relative;
  1665. image {
  1666. width: 40rpx;
  1667. height: 40rpx;
  1668. position: absolute;
  1669. right: 0px;
  1670. }
  1671. }
  1672. .tree {
  1673. display: flex;
  1674. height: 546rpx;
  1675. .left {
  1676. overflow-y: auto;
  1677. .item {
  1678. width: 224rpx;
  1679. height: 78rpx;
  1680. padding: 20rpx;
  1681. font-size: 26rpx;
  1682. }
  1683. .active {
  1684. background: rgba(68, 154, 255, 0.1);
  1685. color: #2983EC;
  1686. }
  1687. }
  1688. .border {
  1689. border-left: 1px solid #eeeeee;
  1690. border-right: 1px solid #eeeeee;
  1691. }
  1692. }
  1693. .sub {
  1694. display: flex;
  1695. justify-content: space-between;
  1696. margin-top: 16rpx;
  1697. border-top: 1px solid #eeeeee;
  1698. padding-top: 16rpx;
  1699. .submit {
  1700. width: 672rpx;
  1701. height: 76rpx;
  1702. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  1703. border-radius: 53rpx;
  1704. display: flex;
  1705. align-items: center;
  1706. justify-content: center;
  1707. font-size: 28rpx;
  1708. color: #FFFFFF;
  1709. }
  1710. }
  1711. }
  1712. }
  1713. }
  1714. ::v-deep.u-upload__button {
  1715. width: 250rpx !important;
  1716. height: 250rpx !important;
  1717. }
  1718. .exchange-input {
  1719. display: flex;
  1720. justify-content: space-between;
  1721. height: 65rpx;
  1722. background: #F7F8FC;
  1723. border-radius: 12rpx;
  1724. margin-bottom: 20rpx;
  1725. padding: 20rpx;
  1726. font-size: 28rpx;
  1727. width: 100%;
  1728. .exchange-all {
  1729. color: #333333;
  1730. font-size: 28rpx;
  1731. }
  1732. input {
  1733. font-size: 28rpx;
  1734. }
  1735. }
  1736. .customize {
  1737. margin-bottom: 16rpx;
  1738. background-color: #ffffff;
  1739. border-radius: 16rpx;
  1740. .title {
  1741. padding: 18upx 0;
  1742. font-size: 28upx;
  1743. // padding: 10px;
  1744. }
  1745. .business-img {
  1746. height: 210upx;
  1747. width: 310upx;
  1748. background-size: cover;
  1749. image {
  1750. width: 100%;
  1751. height: 100%;
  1752. }
  1753. }
  1754. .uploader_video {
  1755. width: 310upx;
  1756. height: 210upx;
  1757. }
  1758. .video-container {
  1759. max-width: 100%;
  1760. /* 最大宽度为父容器宽度 */
  1761. max-height: 100%;
  1762. ::v-deep.uni-video-bar {
  1763. height: 62upx;
  1764. padding: 0
  1765. }
  1766. }
  1767. }
  1768. .uni-uploader__file,
  1769. .uploader_video {
  1770. position: relative;
  1771. z-index: 1;
  1772. width: 200upx;
  1773. height: 200upx;
  1774. }
  1775. .icon-cuo {
  1776. position: absolute;
  1777. right: 0;
  1778. top: 5upx;
  1779. color: #FFFFFF !important;
  1780. z-index: 999;
  1781. border-top-right-radius: 20upx;
  1782. border-bottom-left-radius: 20upx;
  1783. }
  1784. .business-prompt {
  1785. padding-top: 16upx;
  1786. font-size: 20upx;
  1787. color: #999999;
  1788. }
  1789. .item_tips {
  1790. font-size: 20rpx;
  1791. color: #999999;
  1792. margin-bottom: 16rpx;
  1793. margin-top: -15rpx;
  1794. }
  1795. .saletime {
  1796. padding-top: 10rpx;
  1797. }
  1798. /* 添加radio样式 */
  1799. .radio-group {
  1800. display: flex;
  1801. justify-content: space-between;
  1802. align-items: center;
  1803. }
  1804. ::v-deep .uni-data-checklist .checklist-group {
  1805. display: flex;
  1806. flex-direction: column;
  1807. flex-wrap: wrap;
  1808. }
  1809. ::v-deep .editor-container {
  1810. height: 260rpx;
  1811. }
  1812. ::v-deep .uni-table-tr .checkbox {
  1813. padding: 0;
  1814. width: 30rpx;
  1815. // width: 24px; /* 可以根据需要调整宽度 */
  1816. // height: 24px; /* 保持宽高一致 */
  1817. }
  1818. ::v-deep .uni-table-th[data-v-511e81f9] {
  1819. padding: 15rpx;
  1820. }
  1821. .item_weekTime {
  1822. display: flex;
  1823. justify-content: space-around;
  1824. }
  1825. .sellingTimeCard {
  1826. border: 1rpx solid #E5E5E5;
  1827. margin-top: 16rpx;
  1828. }
  1829. </style>