shopdetail.vue 42 KB

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