editGoods.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="goods-img-block flex flex-center">
  5. <view class="add-btn" @click="ChooseImage">
  6. <image v-if="cove_image" class="logo-img" :src="cove_image">
  7. </image>
  8. <image v-else-if="thumb" class="logo-img" :src="URL+''+thumb">
  9. </image>
  10. <image v-else src="../static/images/icon_18.png" mode="aspectFit" class="add-img-btn"></image>
  11. <view class="btn-name">添加商品主图</view>
  12. </view>
  13. </view>
  14. <view class="page-block">
  15. <view class="page-title-block">
  16. <view class="title">基本信息</view>
  17. </view>
  18. <view class="content">
  19. <view @click="bindCommodity" class="cell flex flex-y-center arr-r" v-if="!id">
  20. <view class="title-block ">
  21. <text>商品库</text>
  22. </view>
  23. <view class="desc"></view>
  24. </view>
  25. <view class="cell flex flex-y-center">
  26. <view class="title-block required">
  27. <text>商品名称</text>
  28. </view>
  29. <view class="desc">
  30. <input type="text" :value="info.name" name="name" class="input-box" placeholder="请输入商品名称"
  31. placeholder-class="desc-placeholder">
  32. </view>
  33. </view>
  34. <view class="cell flex flex-y-center arr-r">
  35. <view class="title-block required">
  36. <text>商品分类</text>
  37. </view>
  38. <view class="desc">
  39. <picker mode="selector" :range="goodsTypeList" @change="onGoodsTypeChange"
  40. :range-key="'title'">
  41. <view :class="[goodsType?'':'desc-placeholder','input-box']">{{goodsType || '请选择'}}
  42. </view>
  43. </picker>
  44. </view>
  45. </view>
  46. <view class="cell flex flex-y-center arr-r">
  47. <view class="title-block">
  48. <text>打印标签</text>
  49. </view>
  50. <view class="desc">
  51. <picker mode="selector" :range="listlabel" @change="onlabelTypeChange"
  52. :range-key="'tag_name'">
  53. <view :class="[labelType?'':'desc-placeholder','input-box']">{{labelType || '请选择'}}
  54. </view>
  55. </picker>
  56. </view>
  57. </view>
  58. <view class="cell flex flex-y-center">
  59. <view class="title-block">
  60. <text>商品条形码</text>
  61. </view>
  62. <view class="desc">
  63. <input :value="info.bar_number" name="bar_number"
  64. class="input-box" placeholder="请输入"
  65. placeholder-class="desc-placeholder">
  66. </view>
  67. </view>
  68. <view class="cell flex flex-y-center">
  69. <view class="title-block">
  70. <text>商品销量</text>
  71. </view>
  72. <view class="desc">
  73. <input type="number" :value="info.sales" name="sales" class="input-box" placeholder="请输入"
  74. placeholder-class="desc-placeholder">
  75. </view>
  76. </view>
  77. <view class="cell flex flex-y-center">
  78. <view class="title-block">
  79. <text>商品单位</text>
  80. </view>
  81. <view class="desc">
  82. <input type="text" :value="info.unit" name="unit" class="input-box" placeholder="请输入"
  83. placeholder-class="desc-placeholder">
  84. </view>
  85. </view>
  86. <view class="cell flex flex-y-center">
  87. <view class="title-block">
  88. <text>商品状态</text>
  89. </view>
  90. <view class="desc">
  91. <view class="desc flex-center">
  92. <view class="checklist-box " @click="choicepay(index)"
  93. v-for="(item,index) of goods_list" :key='index' :class="is_goods==index?'actt':''">
  94. <view class="radio__inner" :class="is_goods==index?'act_border':''">
  95. <view :class="is_goods==index?'is-default-checked':''"
  96. class="radio__inner-icon radio__inner-icon ">
  97. </view>
  98. </view>
  99. <text class="checklist-text">{{item}}</text>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="cell flex flex-y-center">
  105. <view class="title-block">
  106. <text>是否开启起购</text>
  107. </view>
  108. <view class="desc">
  109. <view class="desc flex-center">
  110. <view class="checklist-box " @click="choiceRebate(index)"
  111. v-for="(item,index) of rebate_list" :key='index' :class="is_rebate==index?'actt':''">
  112. <view class="radio__inner" :class="is_rebate==index?'act_border':''">
  113. <view :class="is_rebate==index?'is-default-checked':''"
  114. class="radio__inner-icon radio__inner-icon ">
  115. </view>
  116. </view>
  117. <text class="checklist-text">{{item}}</text>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <view v-show="is_rebate==1">
  123. <view class="cell flex flex-y-center">
  124. <view class="title-block">
  125. <text>第一份商品金额</text>
  126. </view>
  127. <view class="desc">
  128. <input type="text" :value="info.first_price" name="first_price" class="input-box" placeholder="请输入"
  129. placeholder-class="desc-placeholder">
  130. </view>
  131. </view>
  132. <view class="cell flex flex-y-center">
  133. <view class="title-block">
  134. <text>第几折</text>
  135. </view>
  136. <view class="desc">
  137. <input type="text" :value="info.rebate" name="rebate" class="input-box" placeholder="请输入"
  138. placeholder-class="desc-placeholder">
  139. </view>
  140. </view>
  141. <view class="cell flex flex-y-center">
  142. <view class="title-block">
  143. <text>第几件商品起购</text>
  144. </view>
  145. <view class="desc">
  146. <input type="text" :value="info.many_rebate" name="many_rebate" class="input-box" placeholder="请输入"
  147. placeholder-class="desc-placeholder">
  148. </view>
  149. </view>
  150. <view class="cell flex flex-y-center">
  151. <view class="title-block">
  152. <text>虚拟销量</text>
  153. </view>
  154. <view class="desc">
  155. <input type="text" :value="info.fictitious" name="fictitious" class="input-box" placeholder="请输入"
  156. placeholder-class="desc-placeholder">
  157. </view>
  158. </view>
  159. </view>
  160. <view class="cell flex flex-y-center">
  161. <view class="title-block">
  162. <text>必选商品</text>
  163. </view>
  164. <view class="desc">
  165. <view class="desc flex-center">
  166. <view class="checklist-box " @click="choicepayBx(index)"
  167. v-for="(item,index) of mandatory_list" :key='index'
  168. :class="is_mandatory==index?'actt':''">
  169. <view class="radio__inner" :class="is_mandatory==index?'act_border':''">
  170. <view :class="is_mandatory==index?'is-default-checked':''"
  171. class="radio__inner-icon radio__inner-icon ">
  172. </view>
  173. </view>
  174. <text class="checklist-text">{{item}}</text>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. <block v-if="is_mandatory==1">
  180. <view class="cell flex flex-y-center">
  181. <view class="title-block">
  182. <text>外卖必选</text>
  183. </view>
  184. <view class="desc">
  185. <view class="desc flex-center">
  186. <view class="checklist-box " @click="choiceOutside(index)"
  187. v-for="(item,index) of outside_list" :key='index'
  188. :class="is_outside==index?'actt':''">
  189. <view class="radio__inner" :class="is_outside==index?'act_border':''">
  190. <view :class="is_outside==index?'is-default-checked':''"
  191. class="radio__inner-icon radio__inner-icon ">
  192. </view>
  193. </view>
  194. <text class="checklist-text">{{item}}</text>
  195. </view>
  196. </view>
  197. </view>
  198. </view>
  199. <view class="cell flex flex-y-center">
  200. <view class="title-block">
  201. <text>堂食必选</text>
  202. </view>
  203. <view class="desc">
  204. <view class="desc flex-center">
  205. <view class="checklist-box " @click="choiceCanteen(index)"
  206. v-for="(item,index) of canteen_list" :key='index'
  207. :class="is_canteen==index?'actt':''">
  208. <view class="radio__inner" :class="is_canteen==index?'act_border':''">
  209. <view :class="is_canteen==index?'is-default-checked':''"
  210. class="radio__inner-icon radio__inner-icon ">
  211. </view>
  212. </view>
  213. <text class="checklist-text">{{item}}</text>
  214. </view>
  215. </view>
  216. </view>
  217. </view>
  218. <view class="cell flex flex-y-center">
  219. <view class="title-block">
  220. <text>自提必选</text>
  221. </view>
  222. <view class="desc">
  223. <view class="desc flex-center">
  224. <view class="checklist-box " @click="choiceTake(index)"
  225. v-for="(item,index) of take_list" :key='index'
  226. :class="is_take==index?'actt':''">
  227. <view class="radio__inner" :class="is_take==index?'act_border':''">
  228. <view :class="is_take==index?'is-default-checked':''"
  229. class="radio__inner-icon radio__inner-icon ">
  230. </view>
  231. </view>
  232. <text class="checklist-text">{{item}}</text>
  233. </view>
  234. </view>
  235. </view>
  236. </view>
  237. </block>
  238. <view class="cell flex flex-y-center">
  239. <view class="title-block">
  240. <text>无限库存</text>
  241. </view>
  242. <view class="desc">
  243. <view class="desc flex-center">
  244. <view class="checklist-box " @click="choicepayKc(index)"
  245. v-for="(item,index) of pion_list" :key='index' :class="is_pion==index?'actt':''">
  246. <view class="radio__inner" :class="is_pion==index?'act_border':''">
  247. <view :class="is_pion==index?'is-default-checked':''"
  248. class="radio__inner-icon radio__inner-icon ">
  249. </view>
  250. </view>
  251. <text class="checklist-text">{{item}}</text>
  252. </view>
  253. </view>
  254. </view>
  255. </view>
  256. <view class="cell flex flex-y-center">
  257. <view class="title-block">
  258. <text>是否启用规格</text>
  259. </view>
  260. <view class="desc">
  261. <view class="desc flex-center">
  262. <view class="checklist-box " @click="choicepaySpec(index)"
  263. v-for="(item,index) of spec_list" :key='index' :class="is_gg==index?'actt':''">
  264. <view class="radio__inner" :class="is_gg==index?'act_border':''">
  265. <view :class="is_gg==index?'is-default-checked':''"
  266. class="radio__inner-icon radio__inner-icon ">
  267. </view>
  268. </view>
  269. <text class="checklist-text">{{item}}</text>
  270. </view>
  271. </view>
  272. </view>
  273. </view>
  274. </view>
  275. </view>
  276. <view class="page-block" @click="onSpec" v-if="is_gg==1">
  277. <view class="page-title-block">
  278. <view class="title">商品规格</view>
  279. </view>
  280. <view class="content ">
  281. <view class="cell flex flex-y-center box-pack-between">
  282. <view class="title-block">
  283. <text>商品规格</text>
  284. </view>
  285. <view class="flex-y-center" style="font-size: 26rpx;color: #999;">
  286. <text>{{tableList.length?'已设置':'未设置'}}</text>
  287. <text class="iconfont icongengduo"></text>
  288. </view>
  289. </view>
  290. </view>
  291. <view class="ft24" style="padding: 20rpx;color:red;">
  292. *商品规格设置完成,需提交才可生效
  293. </view>
  294. </view>
  295. <!-- -->
  296. <view class="page-block">
  297. <view class="page-title-block">
  298. <view class="title">商品价格</view>
  299. </view>
  300. <view class="content">
  301. <view class="cell flex flex-y-center">
  302. <view class="title-block required">
  303. <text>商品售价</text>
  304. </view>
  305. <view class="desc">
  306. <input type="digit" :value="info.price" name="price" class="input-box" placeholder="请输入商品售价"
  307. placeholder-class="desc-placeholder">
  308. </view>
  309. </view>
  310. <view class="cell flex flex-y-center">
  311. <view class="title-block required">
  312. <text>商品库存</text>
  313. </view>
  314. <view class="desc">
  315. <input type="number" :value="info.stock" name="stock" class="input-box"
  316. placeholder="请输入商品库存" placeholder-class="desc-placeholder">
  317. </view>
  318. </view>
  319. <view class="cell">
  320. <view class="flex flex-y-center">
  321. <view class="title-block">
  322. <text>包装费</text>
  323. </view>
  324. <view class="desc">
  325. <input type="number" :value="info.box_fee" name="box_fee" class="input-box"
  326. placeholder="请输入包装费" placeholder-class="desc-placeholder">
  327. </view>
  328. </view>
  329. <view class="ft22" style="color: red;">说明: 只限外卖自提订单</view>
  330. </view>
  331. <view class="cell flex flex-y-center">
  332. <view class="title-block">
  333. <text>智豆规则</text>
  334. </view>
  335. <view class="desc">
  336. <view class="desc flex-center">
  337. <view class="checklist-box " @click="choiceZhidou(index)"
  338. v-for="(item,index) of zhidou_list" :key='index' :class="is_zhidou==index?'actt':''">
  339. <view class="radio__inner" :class="is_zhidou==index?'act_border':''">
  340. <view :class="is_zhidou==index?'is-default-checked':''"
  341. class="radio__inner-icon radio__inner-icon ">
  342. </view>
  343. </view>
  344. <text class="checklist-text">{{item}}</text>
  345. </view>
  346. </view>
  347. </view>
  348. </view>
  349. <view class="cell">
  350. <view class="flex flex-y-center">
  351. <view class="title-block">
  352. <text>赠送智豆</text>
  353. </view>
  354. <view class="desc">
  355. <input type="number" :value="info.zhidou" name="zhidou"
  356. class="input-box" placeholder="请输入赠送智豆"
  357. placeholder-class="desc-placeholder">
  358. </view>
  359. </view>
  360. <view class="ft22" style="color: red;">说明: 如果商户智豆不足,则智豆无法成功赠送给消费者。</view>
  361. </view>
  362. <view class="cell">
  363. <view class="flex flex-y-center">
  364. <view class="title-block">
  365. <text>佣金比例</text>
  366. </view>
  367. <view class="desc">
  368. <input type="number" :value="info.shared_commission" name="shared_commission"
  369. class="input-box" placeholder="请输入佣金比例"
  370. placeholder-class="desc-placeholder">
  371. </view>
  372. </view>
  373. <view class="ft22" style="color: red;">说明 : 应用于合伙人商品佣金;%,若是开启了分账打款的话不能超过25%</view>
  374. </view>
  375. <view class="cell flex flex-y-center">
  376. <view class="title-block">
  377. <text>排序</text>
  378. </view>
  379. <view class="desc">
  380. <input type="number" :value="info.sort" name="sort" class="input-box"
  381. placeholder="请输入排序"
  382. placeholder-class="desc-placeholder">
  383. </view>
  384. </view>
  385. </view>
  386. </view>
  387. <view class="page-block">
  388. <view class="page-title-block">
  389. <view class="title">视频号</view>
  390. </view>
  391. <view class="content">
  392. <view class="cell flex flex-y-center">
  393. <view class="title-block">
  394. <text>视频号主页id</text>
  395. </view>
  396. <view class="desc">
  397. <input :value="info.finder" name="finder" class="input-box"
  398. placeholder="请输入视频号主页id"
  399. placeholder-class="desc-placeholder">
  400. </view>
  401. </view>
  402. <view class="cell flex flex-y-center">
  403. <view class="title-block">
  404. <text>视频号视频id</text>
  405. </view>
  406. <view class="desc">
  407. <input :value="info.feedid" name="feedid" class="input-box" placeholder="请输入视频号视频id"
  408. placeholder-class="desc-placeholder">
  409. </view>
  410. </view>
  411. </view>
  412. </view>
  413. <view class="page-block">
  414. <view class="page-title-block"></view>
  415. <view class="content">
  416. <view class="cell flex flex-y-center box-pack-between">
  417. <view class="title-block">
  418. <text>商品详情</text>
  419. </view>
  420. <view class="flex-center" v-if="id" @click="getEnit">
  421. <text style="color: #007AFF;">{{is_enit?'取消编辑':'编辑'}}</text>
  422. <text class="iconfont icongengduo"></text>
  423. </view>
  424. </view>
  425. </view>
  426. <view class="content">
  427. <view v-if="id">
  428. <block v-if="is_enit">
  429. <textarea style="width: 100%;" :value="info.description" name="description"
  430. placeholder="输入商品详情" />
  431. </block>
  432. <block v-else>
  433. <rich-text :nodes="info.description"></rich-text>
  434. <textarea style="width: 100%;display: none;" :value="info.description" name="description"
  435. placeholder="" />
  436. </block>
  437. </view>
  438. <block v-else>
  439. <textarea style="width: 100%;" :value="info.description" name="description"
  440. placeholder="输入商品详情" />
  441. </block>
  442. </view>
  443. </view>
  444. <!-- -->
  445. <view style="height: 30rpx;"></view>
  446. <!-- -->
  447. <view class="footer-bar">
  448. <view class="content flex flex-center" style="background: none;position: relative;">
  449. <button class="btn" hover-class="none" form-type="submit">
  450. 立即提交
  451. </button>
  452. </view>
  453. </view>
  454. <!-- -->
  455. </form>
  456. </view>
  457. </template>
  458. <script>
  459. export default {
  460. data() {
  461. return {
  462. URL: getApp().globalData.URL,
  463. thumb: "",
  464. store_id: "",
  465. imgid: "",
  466. goods_list: [
  467. "下架", "上架",
  468. ],
  469. is_goods: 0,
  470. rebate_list:[
  471. "不启用", "启用",
  472. ],
  473. is_rebate:0,
  474. mandatory_list: [
  475. "不启用", "启用",
  476. ],
  477. is_mandatory: 0,
  478. outside_list: [
  479. "不启用", "启用",
  480. ],
  481. is_outside: 0,
  482. canteen_list: [
  483. "不启用", "启用",
  484. ],
  485. is_canteen: 0,
  486. take_list: [
  487. "不启用", "启用",
  488. ],
  489. is_take: 0,
  490. pion_list: [
  491. "不启用", "启用",
  492. ],
  493. is_pion: 0,
  494. zhidou_list: [
  495. "数量", "百分比",
  496. ],
  497. is_zhidou: 0,
  498. spec_list:[
  499. "不启用","启用",
  500. ],
  501. is_gg:0,
  502. goodsTypeList: [],
  503. goodsType: "",
  504. goodsTypeid: "",
  505. listlabel: [],
  506. labelType: "",
  507. labelTypeid: "",
  508. info: {},
  509. id: "",
  510. is_enit: false,
  511. is_out:true,
  512. tableList:null,
  513. edit_value:null,
  514. mySpecList:null,
  515. cove_image:'',
  516. }
  517. },
  518. onLoad(e) {
  519. this.store_id = uni.getStorageSync("store_id");
  520. this.storeinfo();
  521. this.getData();
  522. if (e.id) {
  523. this.id = e.id;
  524. this.goodsinfo(e.id);
  525. }
  526. },
  527. methods: {
  528. bindCommodity(){
  529. uni.navigateTo({
  530. url:"./goods"
  531. })
  532. },
  533. onSpec(){
  534. let id = '';
  535. if(this.tableList && this.mySpecList){
  536. id = 'spec'
  537. uni.setStorageSync('obj'+id,{
  538. edit_value: this.edit_value,spec:JSON.parse(this.mySpecList),spec_val:JSON.parse(this.tableList),
  539. })
  540. }else{
  541. if(this.id){
  542. let {edit_value,spec,spec_val } = this.info
  543. id = this.info.id
  544. uni.setStorageSync('obj'+id,{
  545. edit_value,spec,spec_val,
  546. })
  547. }
  548. }
  549. uni.navigateTo({
  550. url:'./specs?id='+ id
  551. })
  552. },
  553. getEnit() {
  554. this.is_enit = !this.is_enit;
  555. },
  556. onGoodsTypeChange(e) {
  557. this.goodsType = this.goodsTypeList[e.detail.value].title;
  558. this.goodsTypeid = this.goodsTypeList[e.detail.value].id;
  559. },
  560. onlabelTypeChange(e) {
  561. this.labelType = this.listlabel[e.detail.value].tag_name;
  562. this.labelTypeid = this.listlabel[e.detail.value].id;
  563. },
  564. storeinfo() {
  565. this.request({
  566. url: 'Smdcshop/cygoods_category_index',
  567. data: {
  568. store_id: uni.getStorageSync("store_id")
  569. }
  570. }).then(res => {
  571. if (res.code == 200) {
  572. this.goodsTypeList = res.data
  573. }
  574. })
  575. },
  576. goodsinfo(id) {
  577. this.request({
  578. url: 'Smdcshop/goodsinfo',
  579. data: {
  580. id,
  581. }
  582. }).then(res => {
  583. if (res.code == "200") {
  584. this.info = res.data
  585. this.thumb = res.data.thumb;
  586. for (let i of this.goodsTypeList) {
  587. if (i.id == res.data.category_id) {
  588. this.goodsType = i.title
  589. }
  590. }
  591. this.goodsTypeid = res.data.category_id
  592. for (let i of this.listlabel) {
  593. if (i.id == res.data.label_id) {
  594. this.labelType = i.tag_name
  595. }
  596. }
  597. this.labelTypeid = res.data.label_id
  598. this.is_goods = res.data.status;
  599. this.is_mandatory = res.data.mandatory;
  600. this.is_outside = res.data.outside;
  601. this.is_canteen=res.data.canteen;
  602. this.is_take=res.data.take;
  603. this.is_rebate=res.data.is_rebate;
  604. this.is_pion = res.data.pion;
  605. this.is_zhidou = Number(res.data.is_zhidou)-1;
  606. this.is_gg= Number(res.data.is_gg)-1;
  607. this.edit_value = res.data.edit_value
  608. this.tableList = JSON.stringify(res.data.spec_val);
  609. }
  610. })
  611. },
  612. getData() {
  613. this.request({
  614. url: 'Smdcshop/print_tag',
  615. data: {
  616. store_id: uni.getStorageSync("store_id")
  617. }
  618. }).then(res => {
  619. if (res.code == "200") {
  620. this.listlabel = res.data
  621. }
  622. })
  623. },
  624. choiceRebate(index) {
  625. this.is_rebate = index;
  626. },
  627. choicepay(index) {
  628. this.is_goods = index;
  629. },
  630. choicepayBx(index) {
  631. this.is_mandatory = index;
  632. },
  633. choiceOutside(index){
  634. this.is_outside = index;
  635. },
  636. choiceTake(index){
  637. this.is_take=index;
  638. },
  639. choiceCanteen(index){
  640. this.is_canteen = index;
  641. },
  642. choicepayKc(index) {
  643. this.is_pion = index;
  644. },
  645. choiceZhidou(index) {
  646. this.is_zhidou = index;
  647. },
  648. choicepaySpec(index) {
  649. this.is_gg = index;
  650. },
  651. ChooseImage(e) {
  652. // let type = e.currentTarget.dataset.type;
  653. uni.chooseImage({
  654. count: 1, //默认9
  655. sizeType: ['original','compressed'], //可以指定是原图还是压缩图,默认二者都有
  656. sourceType: ['album','camera'], //从相册选择
  657. success: (res) => {
  658. console.log(res)
  659. this.cove_image ='';
  660. // var tempFilesSize = res.tempFiles[0].size;//获取图片的大小,单位B
  661. res.tempFilePaths.forEach((v, i) => {
  662. // console.log(v)
  663. this.Upload({
  664. url: "Smdcshop/upload",
  665. data: {
  666. url: v,
  667. type: "",
  668. token: "",
  669. admin_id: uni.getStorageSync("admin_id")
  670. }
  671. }).then(res => {
  672. console.log(res, "res")
  673. this.imgid = res.id;
  674. this.thumb = res.src;
  675. }).catch(err => {
  676. uni.showToast({
  677. title: err.message,
  678. icon: 'none'
  679. })
  680. });
  681. })
  682. },
  683. });
  684. },
  685. onSubmit(e) {
  686. // console.log(this.tableList,"tableList")
  687. let params = {
  688. category_id: this.goodsTypeid,
  689. label_id: this.labelTypeid,
  690. status: this.is_goods,
  691. admin_id: uni.getStorageSync("admin_id"),
  692. store_id: this.store_id,
  693. thumb: this.cove_image ?'':this.imgid,
  694. image:this.cove_image||'',
  695. is_rebate:this.is_rebate,
  696. mandatory: this.is_mandatory,
  697. outside:this.is_outside,
  698. canteen:this.is_canteen,
  699. take:this.is_take,
  700. pion: this.is_pion,
  701. bar_number:this.bar_number,
  702. is_zhidou: Number(this.is_zhidou) +1,
  703. spec:this.tableList,
  704. edit_value:this.edit_value,
  705. is_gg: this.is_gg + 1,
  706. // mySpecList:this.mySpecList
  707. },
  708. url= "Smdcshop/goods_save";
  709. var data = Object.assign(params, e.detail.value);
  710. // console.log(data, "data")
  711. if (this.info.id) {
  712. data.id = this.info.id
  713. // url = "Smdcshop/goods_save"
  714. }
  715. // else {
  716. // url = 'Smdcshop/goods_save'
  717. // }
  718. if (!data.name || !data.category_id || !data.price || !data.stock) {
  719. uni.showToast({
  720. title: "必填项不能为空",
  721. icon: 'none'
  722. })
  723. return false
  724. }
  725. // if(!this.is_out){
  726. // setTimeout(()=>{
  727. // this.is_out=true;
  728. // },1000)
  729. // return
  730. // }
  731. // this.is_out=false;
  732. this.request({
  733. url,
  734. data: data
  735. }).then(res => {
  736. if (res.code == 200) {
  737. uni.showToast({
  738. title: res.message,
  739. icon: 'none'
  740. })
  741. setTimeout(() => {
  742. uni.navigateBack()
  743. }, 3000)
  744. }
  745. }).catch((res) => {
  746. uni.showToast({
  747. title: res.message,
  748. icon: 'none'
  749. })
  750. });
  751. },
  752. },
  753. }
  754. </script>
  755. <style>
  756. @import url("../static/css/common.css");
  757. page {
  758. background-color: #f4f5f7;
  759. }
  760. .goods-img-block {
  761. width: 100vw;
  762. height: 70vw;
  763. background-color: #F4F6FA;
  764. }
  765. .goods-img-block .add-btn .add-img-btn {
  766. display: block;
  767. width: 64rpx;
  768. height: 64rpx;
  769. margin: 0 auto;
  770. }
  771. .goods-img-block .add-btn .btn-name {
  772. font-size: 32rpx;
  773. color: #999;
  774. line-height: 45rpx;
  775. margin-top: 16rpx;
  776. }
  777. .checklist-box {
  778. display: -webkit-box;
  779. display: -webkit-flex;
  780. display: flex;
  781. -webkit-box-orient: horizontal;
  782. -webkit-box-direction: normal;
  783. -webkit-flex-direction: row;
  784. flex-direction: row;
  785. -webkit-box-align: center;
  786. -webkit-align-items: center;
  787. align-items: center;
  788. margin: 5px 0;
  789. margin-right: 22px;
  790. }
  791. .radio__inner {
  792. -webkit-flex-shrink: 0;
  793. flex-shrink: 0;
  794. display: -webkit-box;
  795. display: -webkit-flex;
  796. display: flex;
  797. -webkit-box-pack: center;
  798. -webkit-justify-content: center;
  799. justify-content: center;
  800. -webkit-box-align: center;
  801. -webkit-align-items: center;
  802. align-items: center;
  803. position: relative;
  804. border: 1px solid #DCDFE6;
  805. border-radius: 2px;
  806. box-sizing: border-box;
  807. width: 16px;
  808. height: 16px;
  809. border-radius: 16px;
  810. background-color: #fff;
  811. z-index: 1;
  812. -webkit-transition: border-color .3s;
  813. transition: border-color .3s;
  814. }
  815. .radio__inner-icon {
  816. width: 8px;
  817. height: 8px;
  818. border-radius: 10px;
  819. opacity: 0;
  820. -webkit-transition: -webkit-transform .3s;
  821. transition: -webkit-transform .3s;
  822. transition: transform .3s;
  823. transition: transform .3s, -webkit-transform .3s;
  824. }
  825. .is-default-checked {
  826. opacity: 1;
  827. background-color: #007aff;
  828. -webkit-transform: rotate(45deg) scaleY(1);
  829. transform: rotate(45deg) scaleY(1);
  830. }
  831. page .act_border {
  832. border-color: #007aff;
  833. }
  834. .checklist-text {
  835. font-size: 28rpx;
  836. margin-left: 5px;
  837. -webkit-transition: color 0.2s;
  838. transition: color 0.2s;
  839. color: #000;
  840. }
  841. /* */
  842. </style>