shopdetail.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. <template>
  2. <view class="shopdetail">
  3. <view class="shopdetail-content">
  4. <!-- 所属店铺 -->
  5. <view class="shop detail-list">
  6. <view class="menu">
  7. <view class="uni-list-cell">
  8. <view class="uni-list-cell-db">
  9. <picker
  10. class="selectlist"
  11. mode="selector"
  12. @change="changeStore"
  13. :value="storeIndex"
  14. :range="storeList"
  15. :disabled="storeDisable"
  16. range-key="name"
  17. >
  18. <view class="uni-input title">{{
  19. storeList[storeIndex].name
  20. }}</view>
  21. </picker>
  22. <image
  23. src="../../static/images/moreicon.png"
  24. class="more"
  25. ></image>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 商品类型 -->
  31. <view class="shoptype detail-list">
  32. <view class="menu">
  33. <view class="uni-list-cell">
  34. <view class="uni-list-cell-db">
  35. <picker
  36. @change="changeType"
  37. :value="typeIndex"
  38. :range="typeList"
  39. :disabled="typeDisabled"
  40. range-key="name"
  41. class="selectlist"
  42. >
  43. <view class="uni-input title">{{
  44. typeList[typeIndex].name
  45. }}</view>
  46. </picker>
  47. <image
  48. src="../../static/images/moreicon.png"
  49. class="more"
  50. ></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 商品名称 -->
  56. <view class="shopname detail-list">
  57. <!-- <view class="menu" v-if="hasNameList === 1"> -->
  58. <view class="menu" v-if="typeProperty === '1'">
  59. <view class="uni-list-cell">
  60. <view class="uni-list-cell-db">
  61. <picker
  62. @change="changeShop"
  63. :value="shopIndex"
  64. :range="shopList"
  65. :disabled="nameDisabled"
  66. range-key="name"
  67. class="selectlist"
  68. >
  69. <view class="uni-input title">{{
  70. shopList[shopIndex].name
  71. }}</view>
  72. </picker>
  73. <image
  74. src="../../static/images/moreicon.png"
  75. class="more"
  76. ></image>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- <view class="menu" v-if="hasNameList === 0"> -->
  81. <view class="menu" v-if="typeProperty === '0'">
  82. <input
  83. class="input-shopname"
  84. type="text"
  85. v-model="shopname"
  86. placeholder-style="color:#a2a8a8;font-size:28upx"
  87. placeholder="请输入商品名称"
  88. />
  89. </view>
  90. </view>
  91. <!-- 自定义分类 -->
  92. <view class="classify detail-list noborder">
  93. <view class="menu">
  94. <view class="title bigtitle">自定义分类</view>
  95. <view class="txt" @tap="toClassify">管理分类</view>
  96. </view>
  97. </view>
  98. <!-- 西线推荐 -->
  99. <view class="xiline detail-list">
  100. <view class="menu">
  101. <view class="uni-list-cell">
  102. <view class="uni-list-cell-db">
  103. <picker
  104. @change="changeClassify"
  105. :value="lineIndex"
  106. :range="lineList"
  107. :disabled="lineDidsable"
  108. range-key="name"
  109. class="selectlist"
  110. >
  111. <view class="uni-input title">{{
  112. lineList[lineIndex].name
  113. }}</view>
  114. </picker>
  115. <image
  116. src="../../static/images/moreicon.png"
  117. class="more"
  118. ></image>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. <!-- 账号限制 -->
  124. <view class="warp" v-if="typeProperty === '1'">
  125. <view class="idastrict detail-list">
  126. <view class="menu">
  127. <view class="title astricttitle">账号限制</view>
  128. <switch :checked="showoperat" @change="Change" />
  129. </view>
  130. </view>
  131. <view class="detail-list operat" v-if="showoperat">
  132. <view class="menu">
  133. <view class="title">同一账号在</view>
  134. <view class="sub" @tap="subtractUser">-</view>
  135. <text class="num1">{{ astrictDate.data.saleDay }}</text>
  136. <view class="add" @tap="addUser">+</view>
  137. <view class="txt">天内最多购买</view>
  138. <view class="sub" @tap="subtractDate">-</view
  139. ><text class="num2">{{ astrictDate.data.saleNum }}</text
  140. ><view class="add" @tap="addDate">+</view
  141. ><text class="unit">张</text>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="warp" v-if="typeProperty === '0'">
  146. <!-- 卖价 -->
  147. <view class="price-warp">
  148. <view class="name">卖价:</view>
  149. <input
  150. class="price"
  151. type="text"
  152. v-model="price"
  153. placeholder="请输入卖价"
  154. />
  155. </view>
  156. <!-- 打折价 -->
  157. <view class="price-warp">
  158. <view class="name">划线价:</view>
  159. <input
  160. class="price"
  161. type="text"
  162. v-model="rateprice"
  163. placeholder="请输入划线价"
  164. />
  165. </view>
  166. <!-- 销售属性 -->
  167. <view class="property">
  168. <view class="property-warp">
  169. <view class="title">销售属性</view>
  170. <view class="date">
  171. <view class="namebar">过期日期:</view>
  172. <view class="num" @tap="openTime"> {{ expirationDate }}</view>
  173. </view>
  174. <view class="pattern">
  175. <view class="uni-list">
  176. <radio-group @change="radioChange">
  177. <label
  178. class="uni-list-cell uni-list-cell-pd pattern-item"
  179. v-for="(item, index) in patterList"
  180. :key="index"
  181. >
  182. <view class="checkth">
  183. <radio
  184. :value="item.id"
  185. :checked="index === patterIndex"
  186. />
  187. </view>
  188. <view class="txt">
  189. <text class="txt1"> {{ item.name }}</text>
  190. <text> {{ item.know }}</text>
  191. </view>
  192. </label>
  193. </radio-group>
  194. </view>
  195. </view>
  196. </view>
  197. </view>
  198. <!-- 商品库存 -->
  199. <view class="property">
  200. <view class="property-warp">
  201. <view class="title">商品库存</view>
  202. <view class="pattern">
  203. <view class="uni-list">
  204. <radio-group @change="shopNumChange">
  205. <label
  206. class="uni-list-cell uni-list-cell-pd pattern-item"
  207. v-for="(item, index) in shopNumList"
  208. :key="index"
  209. >
  210. <view class="checkth">
  211. <radio
  212. :value="item.id"
  213. :checked="index === shopNumIndex"
  214. />
  215. </view>
  216. <view class="txt">
  217. <text class="txt1"> {{ item.name }}</text>
  218. <text> {{ item.know }}</text>
  219. <view
  220. class="inventory"
  221. v-if="item.name === '限日库存模式'"
  222. >
  223. <text class="name">日库存数:</text>
  224. <input
  225. class="dateInventory"
  226. type="number"
  227. placeholder="请输入库存数量"
  228. v-model="dateInventory"
  229. />
  230. </view>
  231. <view
  232. class="inventory"
  233. v-if="item.name === '限总库存模式'"
  234. >
  235. <text class="name">总库存数:</text>
  236. <input
  237. class="dateInventory"
  238. type="number"
  239. placeholder="请输入库存数量"
  240. v-model="sunInventory"
  241. />
  242. </view>
  243. </view>
  244. </label>
  245. </radio-group>
  246. </view>
  247. </view>
  248. </view>
  249. </view>
  250. <!-- 预定规则 -->
  251. <view class="booking">
  252. <view class="booking-warp">
  253. <view class="title">预定规则</view>
  254. <view class="model">
  255. <view class="inputnum">
  256. <text class="bar">预定数量:</text>
  257. <input
  258. class="bookingnum"
  259. v-model="astrictDate.data.bookRule"
  260. type="number"
  261. placeholder="请输入数量"
  262. />
  263. </view>
  264. <view class="txt">一天内同一身份证可预定数量</view>
  265. </view>
  266. <view class="truename">
  267. <view class="truename-warp">
  268. <view class="txt">是否开启实名制购票</view>
  269. <switch :checked="trueNme" @change="trueNmeChange" />
  270. </view>
  271. </view>
  272. <view class="modeltwo">
  273. <view class="uni-list">
  274. <radio-group @change="bookingChange">
  275. <label
  276. class="uni-list-cell uni-list-cell-pd booking-item"
  277. v-for="(item, index) in bookingList"
  278. :key="index"
  279. >
  280. <view class="checkth">
  281. <radio
  282. :value="item.id"
  283. :checked="index === bookingIndex"
  284. />
  285. </view>
  286. <view class="txt">{{ item.name }}</view>
  287. </label>
  288. </radio-group>
  289. </view>
  290. </view>
  291. <view class="truename">
  292. <view class="truename-warp">
  293. <view class="txt">订单显示二维码</view>
  294. <switch :checked="codeShow" @change="codeShowChange" />
  295. </view>
  296. </view>
  297. </view>
  298. </view>
  299. </view>
  300. <!-- 商品图标 -->
  301. <view class="shopicon">商品图标</view>
  302. <view class="iconcontent">
  303. <image class="shopLogo" :src="iconurl" v-if="iconurl"></image>
  304. <text class="icon" @tap="uploadImg">点击上传</text>
  305. <text class="per"
  306. >{{ uploadtxt }} {{ progress === 0 ? '' : progress }}
  307. <text v-if="progress != 0">%</text></text
  308. >
  309. </view>
  310. <view class="shopicon">商品图册</view>
  311. <view class="uploading">
  312. <view class="item-warp" v-for="(item, index) in pickList" :key="index">
  313. <view class="img-warp">
  314. <image :src="item" class="item list"></image>
  315. <view class="delete">
  316. <image
  317. src="../../static/images/delete.png"
  318. class="delete-icon"
  319. @tap="deleteThisImg(index)"
  320. ></image>
  321. </view>
  322. </view>
  323. </view>
  324. <view class="item-warp">
  325. <image
  326. src="../../static/images/upload.png"
  327. class="item upload"
  328. @tap="uploadList"
  329. ></image>
  330. </view>
  331. </view>
  332. <!-- 购票须知 -->
  333. <view class="shopicon">商品描述(购票须知)</view>
  334. <view class="know">
  335. <view class="container">
  336. <editor
  337. id="editor"
  338. class="ql-container"
  339. :placeholder="placeholderContent"
  340. @input="saveTxt"
  341. @ready="onEditorReady"
  342. ></editor>
  343. </view>
  344. </view>
  345. <view class="btn" @tap="submitMesage">确认</view>
  346. <rf-loading v-if="loading"></rf-loading>
  347. <uni-calendar
  348. ref="calendar"
  349. :insert="false"
  350. :range="false"
  351. @confirm="confirm"
  352. />
  353. </view>
  354. </view>
  355. </template>
  356. <script>
  357. let myCloud;
  358. let _self;
  359. import Header from '../components/header.vue';
  360. import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
  361. import moment from '@/common/moment';
  362. import indexConfig from '@/config/index.config';
  363. export default {
  364. components: {
  365. Header,
  366. uniCalendar,
  367. },
  368. data () {
  369. return {
  370. loading: false,
  371. scenicId: uni.getStorageSync('scenicId'),
  372. title: '商品详情',
  373. showoperat: false,
  374. placeholderContent: '请输入内容...',
  375. mastKnow: '',
  376. storeList: [{ name: '所属店铺', id: '', type: '' }],
  377. storeIndex: 0,
  378. storeId: '',
  379. storeDisable: true,
  380. typeProperty: '1', // 判断所属店铺是否是自营店铺 1分销 0自营
  381. typeList: [{ name: '商品类型(请先选择所属店铺)', id: '' }],
  382. typeIndex: 0,
  383. typeId: '1',
  384. typeDisabled: true,
  385. shopList: [{ name: '商品名称(请先选择商品类型)', id: '' }],
  386. shopIndex: 0,
  387. shopId: '',
  388. shopname: '',
  389. nameDisabled: true,
  390. hasNameList: 0, // 判断是否有商品名称列表
  391. lineList: [{ name: '分类(请先选择所属商品)', id: '' }],
  392. lineIndex: 0,
  393. lineId: '',
  394. lineDidsable: true,
  395. // 图标上传
  396. uploadtxt: '',
  397. progress: 0,
  398. iconurl: '',
  399. pickList: [],
  400. Icon: '',
  401. Imglist: [],
  402. price: 0.0,
  403. rateprice: 0.0,
  404. // -------------- 编辑分界线 ------------------------------------
  405. SHOPID: 0,
  406. shopData: {},
  407. expirationDate: '请选择商品过期日期',
  408. // 销售属性
  409. patterList: [
  410. {
  411. id: '0',
  412. name: '有效期模式',
  413. know: '无需用户指定使用日,在过期时间前均可使用。',
  414. },
  415. {
  416. id: '1',
  417. name: '使用日模式',
  418. know: '用户购买时需选择游玩日,并在游玩日当天使用。',
  419. },
  420. ],
  421. patterIndex: 0,
  422. // 商品库存
  423. shopNumList: [
  424. {id: '0',name: '无限库存模式',know: '售卖商品不计算库存,无限售卖。'},
  425. { id: '1', name: '限日库存模式', know: '每日固定库存售卖。' },
  426. { id: '2', name: '限总库存模式', know: '总库存限制,卖完为止。' },
  427. ],
  428. shopNumIndex: 0,
  429. dateInventory: 0,
  430. sunInventory: 0,
  431. inventory: '',
  432. bookingnum: '',
  433. bookingList: [
  434. { id: '0', name: '未消费统一可退' },
  435. { id: '1', name: '过期不可退' },
  436. { id: '2', name: '统一不可退' },
  437. ],
  438. bookingIndex: 0,
  439. trueNme: false,
  440. codeShow: false,
  441. // 规则参数
  442. astrictDate: {
  443. data: {
  444. saleDay: 1, // 限购天数
  445. saleNum: 1, // 限购票数
  446. dateSetting: '0', // 有效期模式
  447. goodsStockFlag: '0', // 库存模式
  448. bookRule: '', // 同一天限购
  449. usubscribeRule: '0', // 可退规则
  450. isRealName: '1', // 开启实名制
  451. isShowQrcode: '1', // 显示二维码
  452. },
  453. },
  454. };
  455. },
  456. onUnload () {
  457. uni.removeStorageSync('Id');
  458. },
  459. onShow () {
  460. if (this.storeId != '') {
  461. this.getLine(this.storeId)
  462. }
  463. },
  464. onReady () {
  465. myCloud = uniCloud.init({
  466. provider: 'aliyun',
  467. spaceId: 'db8671a1-69bd-470d-ad59-ba927c88f4a4',
  468. clientSecret: '8nOzV70edtpCd0El6qce3g==',
  469. });
  470. },
  471. onLoad ( option ) {
  472. if (option.id != 'undefined') {
  473. this.SHOPID = option.id
  474. this.getShopBuyId(option.id).then(() => {
  475. this.getShopList().then(() => {
  476. this.getShopName(this.typeId, this.storeId);
  477. });
  478. // 数据回显
  479. this.price = this.shopData.salePrice / 100;
  480. this.rateprice = this.shopData.price / 100;
  481. if (this.shopData.expiredTime) {
  482. this.expirationDate = this.shopData.expiredTime.slice(0, 10)
  483. ? this.shopData.expiredTime.slice(0, 10)
  484. : '请选择商品过期日期';
  485. }
  486. // 图标回显
  487. if (this.shopData.icon) {
  488. this.Icon = this.shopData.icon
  489. this.iconurl = this.shopData.icon;
  490. }
  491. // 图册回显
  492. if (this.shopData.imges) {
  493. this.Imglist = JSON.parse(this.shopData.imges)
  494. let urllist = JSON.parse(this.shopData.imges)
  495. urllist.forEach(element => {
  496. this.pickList.push(element.url)
  497. });
  498. }
  499. let rule = JSON.parse(this.shopData.saleRuleJson);
  500. if (rule) {
  501. this.astrictDate.data.saleDay = rule.data.saleDay
  502. ? rule.data.saleDay
  503. : 0;
  504. this.astrictDate.data.saleNum = rule.data.saleNum
  505. ? rule.data.saleNum
  506. : 0;
  507. // 有效期模式
  508. this.astrictDate.dateSetting = rule.data.dateSetting;
  509. this.patterIndex = +rule.data.dateSetting;
  510. // 库存模式
  511. this.astrictDate.goodsStockFlag = rule.data.goodsStockFlag;
  512. this.shopNumIndex = +rule.data.goodsStockFlag;
  513. if (this.shopNumIndex === 1) {
  514. this.dateInventory = this.shopData.inventory;
  515. } else if (this.shopNumIndex === 2) {
  516. this.sunInventory = this.shopData.inventory;
  517. }
  518. // 预订数量
  519. this.astrictDate.data.bookRule = rule.data.bookRule;
  520. // 实名制
  521. if (rule.data.isRealName === '0') {
  522. this.trueNme = true;
  523. } else {
  524. this.trueNme = false;
  525. }
  526. this.astrictDate.data.isRealName = rule.data.isRealName;
  527. // 可退规则
  528. this.bookingIndex = +rule.data.usubscribeRule;
  529. this.astrictDate.usubscribeRule = rule.data.usubscribeRule;
  530. // 二维码
  531. if (rule.data.isShowQrcode === '0') {
  532. this.codeShow = true;
  533. } else {
  534. this.codeShow = false;
  535. }
  536. this.astrictDate.data.isShowQrcode = rule.data.isShowQrcode;
  537. }
  538. // 限制购票回显
  539. if (this.shopData.saleRule === '1') {
  540. this.showoperat = true;
  541. } else {
  542. this.showoperat = false;
  543. }
  544. this.loading = false;
  545. });
  546. } else {
  547. this.getShopList()
  548. }
  549. },
  550. // onPageScroll (option) {
  551. // console.log(option);
  552. // },
  553. methods: {
  554. // 获取单个商品信息
  555. async getShopBuyId (id) {
  556. this.loading = true;
  557. await this.$http.get('/goods/getById/' + id).then((res) => {
  558. if (res.code === 200 && res.msg === 'OK') {
  559. this.shopData = res.data;
  560. this.storeId = res.data.shopId;
  561. this.typeId = res.data.typeId;
  562. this.loading = false;
  563. }
  564. });
  565. },
  566. // 打开日历
  567. openTime () {
  568. this.$refs.calendar.open();
  569. },
  570. confirm (e) {
  571. this.expirationDate = e.fulldate;
  572. },
  573. // 自定义属性
  574. radioChange (evt) {
  575. for (let i = 0; i < this.patterList.length; i++) {
  576. if (this.patterList[i].id === evt.target.value) {
  577. this.patterIndex = i;
  578. break;
  579. }
  580. }
  581. this.astrictDate.data.dateSetting = evt.detail.value;
  582. },
  583. // 库存模式
  584. shopNumChange (e) {
  585. for (let i = 0; i < this.shopNumList.length; i++) {
  586. if (this.shopNumList[i].id === e.target.value) {
  587. this.shopNumIndex = i;
  588. break;
  589. }
  590. }
  591. if (e.detail.value === '1') {
  592. this.sunInventory = 0;
  593. }
  594. if (e.detail.value === '2') {
  595. this.dateInventory = 0;
  596. }
  597. this.astrictDate.data.goodsStockFlag = e.detail.value;
  598. },
  599. // 可退模式
  600. bookingChange (e) {
  601. for (let i = 0; i < this.bookingList.length; i++) {
  602. if (this.bookingList[i].id === e.target.value) {
  603. this.bookingIndex = i;
  604. break;
  605. }
  606. }
  607. this.astrictDate.data.usubscribeRule = e.detail.value;
  608. },
  609. // 实名制
  610. trueNmeChange (e) {
  611. if (e.detail.value) {
  612. this.astrictDate.data.isRealName = '0';
  613. } else {
  614. this.astrictDate.data.isRealName = '1';
  615. }
  616. },
  617. // 显示二维码
  618. codeShowChange (e) {
  619. if (e.detail.value) {
  620. this.astrictDate.data.isShowQrcode = '0';
  621. } else {
  622. this.astrictDate.data.isShowQrcode = '1';
  623. }
  624. },
  625. // 初始化编辑器
  626. onEditorReady () {
  627. // this.placeholderContent = this.shopData.describ
  628. uni
  629. .createSelectorQuery()
  630. .select('#editor')
  631. .context((res) => {
  632. this.editorCtx = res.context;
  633. this.editorCtx.setContents({
  634. html: this.shopData.describ, //this.EditGoodsDetail.content为赋值内容。
  635. });
  636. })
  637. .exec(-1000)
  638. },
  639. // -----------------------------------------------------------------
  640. // 跳转到管理分类页面
  641. toClassify () {
  642. if (this.storeId) {
  643. uni.setStorageSync('shopid', this.storeId);
  644. this.$mRouter.push({ route: '/pages/shop/classify' });
  645. } else {
  646. this.$mHelper.toast('请选择所属店铺后再进行自定义分类管理');
  647. }
  648. },
  649. // 选择店铺
  650. changeStore (e) {
  651. this.storeIndex = e.detail.value;
  652. this.storeId = this.storeList[this.storeIndex].id;
  653. this.typeProperty = this.storeList[this.storeIndex].type;
  654. if (!this.SHOPID) {
  655. this.getType(this.storeId)
  656. this.getLine(this.storeId)
  657. }
  658. },
  659. // 选择商品类型
  660. changeType (e) {
  661. this.typeIndex = e.detail.value;
  662. this.typeId = this.typeList[this.typeIndex].id;
  663. if (!this.SHOPID) {
  664. this.getShopName(this.typeId, this.storeId);
  665. }
  666. },
  667. // 商品名称选择
  668. changeShop (e) {
  669. this.shopIndex = e.detail.value;
  670. this.shopId = this.shopList[this.shopIndex].id;
  671. },
  672. // 分类
  673. changeClassify (e) {
  674. this.lineIndex = e.detail.value;
  675. this.lineId = this.lineList[this.lineIndex].id;
  676. },
  677. // 所属店铺
  678. async getShopList () {
  679. this.storeList = [{ name: '所属店铺', id: '', type: '' }];
  680. await this.$http
  681. .get('/shop/getList', { mid: this.scenicId })
  682. .then((res) => {
  683. if (res.data) {
  684. let arr = [];
  685. res.data.forEach((element) =>
  686. arr.push({
  687. name: element.name,
  688. id: element.id,
  689. type: element.shopFrom,
  690. })
  691. );
  692. this.storeList = this.storeList.concat(arr);
  693. this.storeDisable = false;
  694. // 所属店铺回显
  695. if (this.shopData.shopId) {
  696. this.storeDisable = true;
  697. this.storeList.forEach((item, index) => {
  698. if (this.shopData.shopId === item.id) {
  699. this.storeIndex = index;
  700. }
  701. });
  702. this.storeId = this.storeList[this.storeIndex].id;
  703. this.typeProperty = this.storeList[this.storeIndex].type;
  704. this.getType(this.storeId);
  705. this.getLine(this.storeId);
  706. }
  707. }
  708. });
  709. },
  710. // 商品类型
  711. async getType (storeId) {
  712. this.typeList = [{ name: '商品类型(请先选择所属店铺)', id: '' }];
  713. this.$http
  714. .get('/type/getTypeListByShopId', {
  715. id: storeId,
  716. })
  717. .then((res) => {
  718. let arr = [];
  719. res.data[0].children.forEach((element) => {
  720. arr.push({ name: element.name, id: element.id });
  721. });
  722. this.typeList = this.typeList.concat(arr);
  723. this.typeDisabled = false;
  724. // 商品类型回显
  725. if (this.shopData.typeId) {
  726. this.typeDisabled = true;
  727. this.typeList.forEach((item, index) => {
  728. if (this.shopData.typeId === item.id) {
  729. this.typeIndex = index;
  730. }
  731. });
  732. this.typeId = this.typeList[this.typeIndex].id;
  733. this.shopname = this.shopData.name;
  734. }
  735. });
  736. },
  737. // 商品名称
  738. async getShopName (typeId, storeId) {
  739. this.shopList = [{ name: '商品名称(请先选择商品类型)', id: '' }];
  740. await this.$http
  741. .get('/goods/getTicketGoods', {
  742. typeId: typeId,
  743. shopId: storeId,
  744. })
  745. .then(async (res) => {
  746. if (res.code === 200) {
  747. let arr = [];
  748. res.data.forEach(element => arr.push({ name: element.ticket_name, id: element.ticket_no }));
  749. this.shopList = this.shopList.concat(arr);
  750. this.nameDisabled = false
  751. // 回显名称
  752. if (this.shopData.name) {
  753. this.loading = true;
  754. if (this.typeProperty != 0) {
  755. this.shopList[0] = { name: this.shopData.name, id: '' };
  756. this.shopIndex = 0
  757. this.shopId = this.shopList[this.shopIndex].id;
  758. if (this.shopList[0].name === this.shopList[1].name) {
  759. this.shopList.length = 1
  760. }
  761. } else {
  762. // 自营商品直接赋值
  763. this.shopname = this.shopData.name;
  764. }
  765. this.loading = false;
  766. }
  767. }
  768. });
  769. },
  770. // 线路分配
  771. async getLine (storeId) {
  772. this.lineList = [{ name: '分类(请先选择所属商品)', id: '' }];
  773. await this.$http
  774. .get('/goods/getCustomGroupList', {
  775. shopId: storeId,
  776. })
  777. .then(async (res) => {
  778. let arr = [];
  779. this.typeProperty = +res.data.shopFrom;
  780. res.data.customGroupList.forEach((element) => {
  781. arr.push({ name: element.name, id: element.id });
  782. });
  783. this.lineList = this.lineList.concat(arr);
  784. this.lineDidsable = false;
  785. // 分类回显
  786. if (this.shopData.customGroupId) {
  787. this.loading = true;
  788. this.lineList.forEach((item, index) => {
  789. if (this.shopData.customGroupId === item.id) {
  790. this.lineIndex = index;
  791. }
  792. });
  793. this.lineId = this.lineList[this.lineIndex].id;
  794. this.loading = false;
  795. }
  796. });
  797. },
  798. // 账号限制
  799. Change (e) {
  800. this.showoperat = e.detail.value;
  801. },
  802. subtractUser () {
  803. if (this.astrictDate.data.saleDay <= 1) {
  804. this.$mHelper.toast('最少一天');
  805. return;
  806. } else {
  807. this.astrictDate.data.saleDay--;
  808. }
  809. },
  810. addUser () {
  811. this.astrictDate.data.saleDay++;
  812. },
  813. subtractDate () {
  814. if (this.astrictDate.data.saleNum <= 1) {
  815. this.$mHelper.toast('最少一张票');
  816. return;
  817. } else {
  818. this.astrictDate.data.saleNum--;
  819. }
  820. },
  821. addDate () {
  822. this.astrictDate.data.saleNum++;
  823. },
  824. // 图标上传
  825. uploadImg () {
  826. let _self = this;
  827. _self.uploadtxt = '上传中...';
  828. _self.progress = 0;
  829. uni.chooseImage({
  830. count: 1,
  831. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  832. sourceType: ['album'], // camera 使用相机 album 从相册中选
  833. success: function (res) {
  834. // 成功则返回图片的本地文件路径列表 tempFilePaths
  835. _self.iconurl = res.tempFilePaths[0];
  836. myCloud.uploadFile({
  837. url: indexConfig.uploadUrl,
  838. filePath: _self.iconurl, // 要上传的文件对象
  839. cloudPath: _self.iconurl, // 要上传的文件对象
  840. name: 'file',
  841. success: (res) => {
  842. if (res.fileID) {
  843. _self.Icon = res.fileID;
  844. }
  845. },
  846. fail: function (msg) { },
  847. onUploadProgress: function (progressEvent) {
  848. _self.progress = Math.round(
  849. (progressEvent.loaded * 100) / progressEvent.total
  850. );
  851. if (_self.progress === 100) {
  852. _self.uploadtxt = '上传成功';
  853. }
  854. },
  855. });
  856. },
  857. fail: function (error) {
  858. _self.uploadtxt = '已取消上传';
  859. },
  860. });
  861. },
  862. // 图册上传
  863. uploadList () {
  864. let _self = this;
  865. uni.chooseImage({
  866. count: 6,
  867. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  868. sourceType: ['album'], // camera 使用相机 album 从相册中选
  869. success: function (res) {
  870. // 成功则返回图片的本地文件路径列表 tempFilePaths
  871. if (_self.pickList.length >= 6) {
  872. _self.$mHelper.toast('最多只可上传6张图片');
  873. } else {
  874. _self.pickList = _self.pickList.concat(res.tempFilePaths).slice(0,6);
  875. _self.Imglist = []
  876. for (let i = 0; i < _self.pickList.length; i++) {
  877. let element = _self.pickList[i];
  878. myCloud.uploadFile({
  879. url: indexConfig.uploadUrl,
  880. filePath: element, // 要上传的文件对象
  881. cloudPath: element,
  882. name: 'file',
  883. onUploadProgress: function (progressEvent) {
  884. // 上传进度回调
  885. let percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
  886. },
  887. success: (res) => {
  888. _self.Imglist.push({url:res.fileID,uid:res.filePath})
  889. },
  890. });
  891. }
  892. }
  893. },
  894. });
  895. },
  896. // 删除图册中的图片
  897. deleteThisImg (index) {
  898. this.pickList.splice(index, 1);
  899. this.Imglist.forEach( (element,i) => {
  900. if (element.uid === this.pickList[index]) {
  901. this.Imglist.splice(i,1)
  902. }
  903. });
  904. },
  905. // 富文本失去焦点保存内容
  906. saveTxt (e) {
  907. this.mastKnow = e.detail.html;
  908. },
  909. // 内容提交
  910. submitMesage () {
  911. let _this = this;
  912. // 判断是否限制账号购买
  913. if (this.showoperat) {
  914. this.showoperat = '1';
  915. } else {
  916. this.showoperat = '0';
  917. this.astrictDate.data.saleDay = 0;
  918. this.astrictDate.data.saleNum = 0;
  919. }
  920. let name = '';
  921. if (this.typeProperty === 1) {
  922. name = this.shopList[this.shopIndex].name;
  923. } else if (this.typeProperty === 0) {
  924. name = this.shopname;
  925. }
  926. if (!this.storeId) {
  927. this.$mHelper.toast('请选择所属商铺!');
  928. return;
  929. }
  930. if (!this.typeId) {
  931. this.$mHelper.toast('请选择商品类型!');
  932. return;
  933. }
  934. if (!name) {
  935. this.$mHelper.toast('请选择商品名称或者输入商品名称!');
  936. return;
  937. }
  938. if (this.typeProperty === 0) {
  939. if (!this.lineId) {
  940. this.$mHelper.toast('请选择商品分类!');
  941. return;
  942. }
  943. if (!this.price) {
  944. this.$mHelper.toast('请输入商品卖价!');
  945. return;
  946. }
  947. if (!this.rateprice) {
  948. this.$mHelper.toast('请输入商品划线价!');
  949. return;
  950. }
  951. if (!this.expirationDate) {
  952. this.$mHelper.toast('请选择商品过期日期');
  953. return;
  954. }
  955. if (this.shopIndex === 0) {
  956. this.inventory = '';
  957. }
  958. if (this.shopNumIndex === 1) {
  959. this.inventory = this.dateInventory;
  960. if (!this.inventory) {
  961. this.$mHelper.toast('请输入日库存数量!');
  962. return;
  963. }
  964. }
  965. if (this.shopNumIndex === 2) {
  966. this.inventory = this.sunInventory;
  967. if (!this.inventory) {
  968. this.$mHelper.toast('请输入总库存数量!');
  969. return;
  970. }
  971. }
  972. if (!this.astrictDate.data.bookRule) {
  973. this.$mHelper.toast('请输入预订数量!');
  974. return;
  975. }
  976. }
  977. this.loading = true;
  978. this.$http
  979. .post('/goods/add', {
  980. id: this.shopData.id || '',
  981. mid: this.scenicId,
  982. shopId: this.storeId,
  983. typeId: this.typeId,
  984. customGroupId: this.lineId,
  985. describ: this.mastKnow,
  986. icon: this.Icon || '',
  987. imges: JSON.stringify(this.Imglist) || '',
  988. del: this.shopData.del || '',
  989. upDown: this.shopData.upDown || '',
  990. saleRule: this.showoperat, // 限制购票
  991. saleRuleJson: JSON.stringify(this.astrictDate),
  992. // 自营
  993. name: name,
  994. salePrice: this.price * 100 || null,
  995. price: this.rateprice * 100 || null,
  996. expiredTime:
  997. this.expirationDate === '请选择商品过期日期'
  998. ? ''
  999. : this.expirationDate,
  1000. inventory: this.inventory,
  1001. })
  1002. .then((res) => {
  1003. if (res.code === 200 && res.msg === 'OK') {
  1004. this.loading = false;
  1005. if (this.shopData.id) {
  1006. this.$mHelper.toast('保存成功,请联系管理员进行审核');
  1007. } else {
  1008. this.$mHelper.toast('添加成功');
  1009. }
  1010. setTimeout(() => {
  1011. this.$mRouter.back();
  1012. }, 500);
  1013. }
  1014. });
  1015. },
  1016. },
  1017. };
  1018. </script>
  1019. <style lang="scss" scoped>
  1020. .shopdetail {
  1021. .shopdetail-content {
  1022. padding: 24upx 0 0upx;
  1023. .detail-list {
  1024. padding: 0 33upx;
  1025. background-color: #ffffff;
  1026. border-bottom: 1px solid #e7e7e7;
  1027. box-sizing: border-box;
  1028. .menu {
  1029. display: flex;
  1030. justify-content: space-between;
  1031. align-items: center;
  1032. height: 93upx;
  1033. .uni-list-cell {
  1034. width: 100%;
  1035. display: flex;
  1036. align-items: center;
  1037. height: 93upx;
  1038. .uni-list-cell-db {
  1039. height: 100%;
  1040. display: flex;
  1041. justify-content: space-between;
  1042. align-items: center;
  1043. .selectlist {
  1044. width: 100%;
  1045. }
  1046. }
  1047. }
  1048. .title {
  1049. font-size: 28upx;
  1050. color: #232828;
  1051. }
  1052. .more {
  1053. width: 15upx;
  1054. height: 26upx;
  1055. }
  1056. .bigtitle {
  1057. font-size: 34upx;
  1058. color: #232828;
  1059. font-weight: 700;
  1060. }
  1061. .input-shopname {
  1062. width: 100%;
  1063. height: 100%;
  1064. }
  1065. .txt {
  1066. color: #a95cff;
  1067. font-weight: 700;
  1068. }
  1069. .linetitle {
  1070. color: #232828;
  1071. }
  1072. .astricttitle {
  1073. font-weight: 700;
  1074. font-size: 32upx;
  1075. color: #232828;
  1076. }
  1077. }
  1078. }
  1079. .noborder {
  1080. border-bottom: none;
  1081. }
  1082. .classify {
  1083. background-color: #f9f9f9;
  1084. }
  1085. .idastrict {
  1086. background-color: #fff;
  1087. }
  1088. .operat {
  1089. background-color: #f9f9f9;
  1090. .menu {
  1091. .title {
  1092. font-size: 28upx;
  1093. color: #232828;
  1094. }
  1095. .sub,
  1096. .add {
  1097. width: 44upx;
  1098. height: 44upx;
  1099. border-radius: 50%;
  1100. border: 1px solid #b4b8b7;
  1101. color: #b4b8b7;
  1102. text-align: center;
  1103. line-height: 40upx;
  1104. font-weight: 700;
  1105. }
  1106. .txt {
  1107. color: #232828;
  1108. font-weight: normal;
  1109. }
  1110. .unit {
  1111. color: #232828;
  1112. }
  1113. }
  1114. }
  1115. .shopicon {
  1116. height: 100upx;
  1117. padding: 0 33upx;
  1118. font-size: 32upx;
  1119. color: #232828;
  1120. font-weight: 700;
  1121. line-height: 100upx;
  1122. }
  1123. .iconcontent {
  1124. padding: 25upx 33upx;
  1125. background-color: #f9f9f9;
  1126. display: flex;
  1127. align-items: center;
  1128. .icon {
  1129. display: inline-block;
  1130. height: 56upx;
  1131. font-size: 28upx;
  1132. color: #a3a8a8;
  1133. border-radius: 50%;
  1134. margin-left: 20upx;
  1135. border: 1px dashed #ccc;
  1136. border-radius: 5%;
  1137. text-align: center;
  1138. line-height: 56upx;
  1139. padding: 0 15upx;
  1140. }
  1141. .shopLogo {
  1142. width: 56upx;
  1143. height: 56upx;
  1144. border-radius: 50%;
  1145. }
  1146. .per {
  1147. margin-left: 50upx;
  1148. color: #a3a8a8;
  1149. }
  1150. }
  1151. .uploading {
  1152. padding: 25upx 33upx;
  1153. display: flex;
  1154. align-items: center;
  1155. flex-wrap: wrap;
  1156. background-color: #fff;
  1157. .item-warp {
  1158. border-radius: 17upx;
  1159. margin-right: 15upx;
  1160. margin-bottom: 15upx;
  1161. box-sizing: border-box;
  1162. overflow: hidden;
  1163. .img-warp {
  1164. position: relative;
  1165. }
  1166. .item {
  1167. width: 160upx;
  1168. height: 160upx;
  1169. }
  1170. &:nth-child(4) {
  1171. margin-right: 0;
  1172. }
  1173. .delete {
  1174. position: absolute;
  1175. right: -35upx;
  1176. top: -35upx;
  1177. width: 70upx;
  1178. height: 70upx;
  1179. border-radius: 50%;
  1180. background-color: #8064f7;
  1181. .delete-icon {
  1182. position: absolute;
  1183. left: 13upx;
  1184. bottom: 13upx;
  1185. width: 14upx;
  1186. height: 14upx;
  1187. }
  1188. }
  1189. }
  1190. }
  1191. .know {
  1192. padding: 24upx 33upx;
  1193. background-color: #fff;
  1194. #editor {
  1195. width: 100%;
  1196. height: 300px;
  1197. }
  1198. }
  1199. .btn {
  1200. width: 100%;
  1201. height: 98upx;
  1202. color: #ffffff;
  1203. font-size: 32upx;
  1204. text-align: center;
  1205. line-height: 98upx;
  1206. background-color: #8064f7;
  1207. margin-top: 27upx;
  1208. letter-spacing: 2upx;
  1209. }
  1210. .price-warp {
  1211. padding: 0 33upx;
  1212. background-color: #ffffff;
  1213. border-bottom: 1px solid #e7e7e7;
  1214. box-sizing: border-box;
  1215. display: flex;
  1216. align-items: center;
  1217. height: 93upx;
  1218. .name {
  1219. font-size: 28upx;
  1220. color: #232828;
  1221. }
  1222. .price {
  1223. flex: 1;
  1224. }
  1225. }
  1226. .property {
  1227. .property-warp {
  1228. .title {
  1229. padding: 20upx 33upx;
  1230. font-size: 34rpx;
  1231. color: #232828;
  1232. font-weight: 700;
  1233. }
  1234. .date {
  1235. padding: 0 33upx;
  1236. display: flex;
  1237. align-items: center;
  1238. border-bottom: 1px solid #e7e7e7;
  1239. background-color: #fff;
  1240. height: 93upx;
  1241. .namebar {
  1242. font-size: 28upx;
  1243. line-height: 93upx;
  1244. color: #232828;
  1245. }
  1246. .num {
  1247. flex: 1;
  1248. height: 100%;
  1249. line-height: 93upx;
  1250. color: #a3a8a8;
  1251. }
  1252. }
  1253. }
  1254. }
  1255. .pattern {
  1256. .pattern-item {
  1257. display: flex;
  1258. border-bottom: 1px solid #e7e7e7;
  1259. .checkth {
  1260. width: 100upx;
  1261. }
  1262. .txt {
  1263. flex: 1;
  1264. display: flex;
  1265. justify-content: center;
  1266. flex-direction: column;
  1267. color: #a3a8a8;
  1268. .txt1 {
  1269. color: #232828;
  1270. font-weight: 700;
  1271. }
  1272. .inventory {
  1273. display: flex;
  1274. align-items: center;
  1275. .name {
  1276. width: 150upx;
  1277. color: #232828;
  1278. }
  1279. .dateInventory {
  1280. flex: 1;
  1281. }
  1282. }
  1283. }
  1284. }
  1285. }
  1286. .booking {
  1287. .booking-warp {
  1288. .title {
  1289. padding: 20upx 33upx;
  1290. font-size: 34rpx;
  1291. color: #232828;
  1292. font-weight: 700;
  1293. }
  1294. .model {
  1295. padding: 20upx 33upx;
  1296. background-color: #fff;
  1297. border-bottom: 1px solid #e7e7e7;
  1298. .inputnum {
  1299. display: flex;
  1300. align-items: center;
  1301. .bar {
  1302. width: 150upx;
  1303. font-size: 28upx;
  1304. font-weight: 700;
  1305. color: #232828;
  1306. }
  1307. .bookingnum {
  1308. flex: 1;
  1309. }
  1310. }
  1311. .txt {
  1312. margin-top: 28upx;
  1313. color: #a3a8a8;
  1314. }
  1315. }
  1316. .truename {
  1317. .truename-warp {
  1318. padding: 20upx 33upx;
  1319. display: flex;
  1320. justify-content: space-between;
  1321. border-bottom: 1px solid #e7e7e7;
  1322. background-color: #fff;
  1323. }
  1324. }
  1325. .modeltwo {
  1326. .booking-item {
  1327. display: flex;
  1328. border-bottom: 1px solid #e7e7e7;
  1329. .checkth {
  1330. width: 100upx;
  1331. }
  1332. .txt {
  1333. flex: 1;
  1334. }
  1335. }
  1336. }
  1337. }
  1338. }
  1339. }
  1340. }
  1341. </style>