shopdetail.vue 43 KB

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