shopdetail.vue 39 KB

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