cat-edit.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. <template>
  2. <app-layout>
  3. <view class="cat-info" v-if="mch_id || mch_id == 0">
  4. <view class='cat-item type cross-center dir-left-nowrap'>
  5. <view class="form-label">分类级别</view>
  6. <view class="select">
  7. <radio-group @change="typeChange" class="dir-left-nowrap main-between">
  8. <label class="dir-left-nowrap cross-center" v-for="item in level" :key="item.value" style="width: 33%;">
  9. <view>
  10. <radio :disabled="id > 0" :color="color" :value="item.value" :checked="item.value == catItem.level"/>
  11. </view>
  12. <view class="select-label" :style="{'color': id > 0 ? '#adadb2' : catItem.level == item.value ? color: '#353535'}">{{item.label}}</view>
  13. </label>
  14. </radio-group>
  15. </view>
  16. </view>
  17. <view class='cat-item cross-center main-between' v-if="catItem.level > 1">
  18. <view class="form-label">
  19. <view><text style="color: #ff4544;">*</text>一级分类</view>
  20. </view>
  21. <view style="flex-grow: 1" @click="getList('one')">
  22. <view class='cat-info dir-right-nowrap cross-center'>
  23. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  24. <text style="color: #353535;width: 90%;text-align: right;" class="t-omit" v-if="parents">{{parents.label}}</text>
  25. <text style="color: #cdcdcd" v-else>请选择归属的一级分类</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class='cat-item cross-center main-between' v-if="catItem.level > 2">
  30. <view class="form-label">
  31. <view><text style="color: #ff4544;">*</text>二级分类</view>
  32. </view>
  33. <view style="flex-grow: 1" @click="getList('two')">
  34. <view class='cat-info dir-right-nowrap cross-center'>
  35. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  36. <text style="color: #353535;width: 90%;text-align: right;" class="t-omit" v-if="parents_two">{{parents_two.label}}</text>
  37. <text style="color: #cdcdcd" v-else>请选择归属的二级分类</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class='cat-item cross-center dir-left-nowrap'>
  42. <view class="form-label"><text style="color: #ff4544;">*</text>分类名称</view>
  43. <view class='dir-left-nowrap price-input cross-center'>
  44. <input placeholder-style="color: #cdcdcd" maxlength="16" placeholder="请输入分类名称" class='input' v-model="catItem.name"></input>
  45. </view>
  46. </view>
  47. <view class='cat-item cross-center dir-left-nowrap'>
  48. <view class="form-label"><text style="color: #ff4544;">*</text>排序</view>
  49. <view class='dir-left-nowrap price-input cross-center'>
  50. <input type="number" placeholder-style="color: #cdcdcd" placeholder="请输入排序" class='input' v-model="catItem.sort"></input>
  51. </view>
  52. </view>
  53. <view class='cat-item cross-center main-between'>
  54. <view class="form-label">
  55. <view>分类图标</view>
  56. <view class="sub-label">200x200</view>
  57. </view>
  58. <view>
  59. <view @click="add('pic_url')" class='cat-info dir-right-nowrap cross-center'>
  60. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  61. <image v-if="catItem.pic_url" class="cat-pic" :src="catItem.pic_url"></image>
  62. <text style="color: #cdcdcd" v-else>请上传分类图标</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view class='cat-item cross-center main-between'>
  67. <view class="form-label">
  68. <view>分类大图</view>
  69. <view class="sub-label">702x212</view>
  70. </view>
  71. <view>
  72. <view @click="add('big_pic_url')" class='cat-info dir-right-nowrap cross-center'>
  73. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  74. <image v-if="catItem.big_pic_url" class="cat-pic big" :src="catItem.big_pic_url"></image>
  75. <text style="color: #cdcdcd" v-else>请上传分类大图</text>
  76. </view>
  77. </view>
  78. </view>
  79. <view class='cat-item cross-center main-between'>
  80. <view class="form-label">
  81. <view>分类广告图</view>
  82. <view class="sub-label">500x184</view>
  83. </view>
  84. <view>
  85. <view @click="add('advert_pic')" class='cat-info dir-right-nowrap cross-center'>
  86. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  87. <image v-if="catItem.advert_pic" class="cat-pic advert" :src="catItem.advert_pic"></image>
  88. <text style="color: #cdcdcd" v-else>请上传分类广告图</text>
  89. </view>
  90. </view>
  91. </view>
  92. <view class='cat-item cross-center main-between' v-if="mch_id == 0">
  93. <view class="form-label">
  94. <view>广告链接</view>
  95. </view>
  96. <view style="flex-grow: 1" @click="getList('ad')">
  97. <view class='cat-info dir-right-nowrap cross-center'>
  98. <image class="to-more" src='/static/image/icon/arrow-right.png'></image>
  99. <text v-if="catItem.advert_url">{{catItem.advert_url}}</text>
  100. <text style="color: #cdcdcd" v-else>请选择链接</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view class='cat-item cross-center main-between'>
  105. <view class="form-label">是否启用</view>
  106. <switch :color="color" style="transform:scale(0.7)" :checked="catItem.status == 1" @change="catItem.status = catItem.status == 0 ? 1:0"></switch>
  107. </view>
  108. <view class='cat-item cross-center main-between'>
  109. <view class="form-label">是否显示</view>
  110. <switch :color="color" style="transform:scale(0.7)" :checked="catItem.is_show == true" @change="catItem.is_show = !catItem.is_show"></switch>
  111. </view>
  112. </view>
  113. <view v-if="mch_id || mch_id == 0" :class="['placeholder', `${iphone_x? 'iphone_x':''}`]"></view>
  114. <view v-if="mch_id || mch_id == 0" :class="['add', `${iphone_x? 'iphone_x':''}`]" >
  115. <view :style="{'background-color':color}" @click="save">保存</view>
  116. </view>
  117. <view :class="['dialog', `${iphone_x?'iphone_x':''}`]" v-if="dialog">
  118. <view class="picker-list">
  119. <view class="main-between picker-header" :style="{'color': color}">
  120. <view @click="dialog=false;">取消</view>
  121. <view @click="submitChoose">确定</view>
  122. </view>
  123. <view v-if="mode == 'ad'" class="picker-type dir-left-nowrap cross-center">
  124. <view @click="toggleType(item.value)" class="picker-type-item box-grow-1" :class="chooseType == item.value ? 'active':''" v-for="item in linkType" :key="item.value" :style="{'color': chooseType == item.value ? color : '#353535','border-color': chooseType == item.value ? color : '#fff'}">{{item.name}}</view>
  125. </view>
  126. <picker-view v-if="pickList.length > 0" indicator-style="height: 34px;" :value="chooseIndex" class="picker" @change="bindChange">
  127. <picker-view-column>
  128. <view v-for="(item,idx) in pickList" :key="idx"
  129. :style="{'color': newIndex == idx ? color : newIndex == idx + 1 || newIndex == idx - 1 ? '#999999' : newIndex == idx + 2 || newIndex == idx - 2 ? '#cdcdcd' : ''}"
  130. class="picker-text t-omit">{{mode == 'ad' ? item.name : item.label}}</view>
  131. </picker-view-column>
  132. </picker-view>
  133. <view class="picker" style="background-color: #fff" v-else-if="pickList.length == 0 && mode == 'ad'"></view>
  134. </view>
  135. </view>
  136. <view class="params-dialog main-center cross-center" v-if="showParams">
  137. <view class="params">
  138. <view class="params-title">{{title}}</view>
  139. <view class="params-list">
  140. <view class="params-item" v-for="item in params" :key="item.key">
  141. <view class="main-center cross-center">
  142. <view class="params-label">{{item.key}}</view>
  143. <view class="params-input">
  144. <input :type="item.number" v-model="item.value">
  145. </view>
  146. </view>
  147. <view class="params-desc">{{item.desc}}</view>
  148. </view>
  149. </view>
  150. <view class="params-buttons dir-left-nowrap cross-center">
  151. <view class="but cancel">
  152. <view @click="showParams=false;">取消</view>
  153. </view>
  154. <view class="line"></view>
  155. <view class="but confirm">
  156. <view @click="paramsConfirm">确认</view>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </app-layout>
  162. </template>
  163. <script>
  164. import { mapState } from "vuex";
  165. import uploadFile from '../../../core/upload.js';
  166. export default {
  167. data() {
  168. return {
  169. dialog: false,
  170. level: [
  171. {value: 1, label:'一级'},{value: 2, label:'二级'},{value: 3, label:'三级'}
  172. ],
  173. iphone_x: false,
  174. showParams: false,
  175. parents: null,
  176. parents_two: null,
  177. mode: '',
  178. params: [],
  179. pickList: [],
  180. linkType: [
  181. {value: 'base', name: '基础'},
  182. {value: 'order', name: '订单'},
  183. {value: 'marketing', name: '营销'},
  184. {value: 'plugin', name: '插件'},
  185. {value: 'diy', name: '微页面'},
  186. ],
  187. chooseType: 'base',
  188. title: '',
  189. linkList: [],
  190. list: [],
  191. mch_id: null,
  192. id: 0,
  193. type: '',
  194. newIndex: 0,
  195. chooseIndex: [0],
  196. catItem: {
  197. level: 1,
  198. name: '',
  199. sort: 100,
  200. pic_url: '',
  201. big_pic_url: '',
  202. advert_pic: '',
  203. status: 1,
  204. advert_url:'',
  205. advert_open_type: '',
  206. advert_params: [],
  207. is_show: 1,
  208. parent_id: '',
  209. },
  210. color: ''
  211. }
  212. },
  213. computed: {
  214. ...mapState({
  215. userInfo: state => state.user.info,
  216. adminImg: state => state.mallConfig.__wxapp_img.app_admin
  217. })
  218. },
  219. methods: {
  220. paramsConfirm() {
  221. for(let item of this.params) {
  222. if(item.is_required && !item.value) {
  223. uni.showToast({
  224. title: item.desc,
  225. icon: 'none',
  226. duration: 1000
  227. });
  228. return false;
  229. }
  230. }
  231. this.dialog = false;
  232. this.showParams = false;
  233. this.catItem.advert_url = this.pickList[this.newIndex].value;
  234. this.catItem.advert_open_type = this.pickList[this.newIndex].open_type;
  235. this.catItem.advert_params = this.params;
  236. },
  237. toggleType(item) {
  238. this.chooseType = item;
  239. this.pickList = [];
  240. this.newIndex = 0;
  241. this.chooseIndex[0] = 0;
  242. setTimeout(()=>{
  243. this.pickList = this.linkList[item];
  244. },200)
  245. },
  246. getList(type) {
  247. this.pickList = [];
  248. this.mode = type;
  249. this.newIndex = 0;
  250. this.chooseIndex[0] = 0;
  251. if(type == 'one') {
  252. let list = [];
  253. for(let item of this.list) {
  254. if(this.catItem.level == 3) {
  255. if(item.children) {
  256. list.push(item)
  257. }
  258. }else {
  259. list.push(item)
  260. }
  261. }
  262. for(let index in list) {
  263. if(this.parents && this.parents.value == list[index].value) {
  264. this.newIndex = +index;
  265. this.chooseIndex[0] = +index;
  266. }
  267. this.pickList.push(list[index])
  268. }
  269. if(this.pickList.length == 0) {
  270. uni.showToast({
  271. title: '暂无可用的一级分类',
  272. icon: 'none',
  273. duration: 1000
  274. });
  275. this.catItem.level--;
  276. return false;
  277. }
  278. this.$nextTick(() => {
  279. this.dialog = true;
  280. })
  281. }
  282. if(type == 'two') {
  283. if(!this.parents) {
  284. uni.showToast({
  285. title: '请选择归属的一级分类',
  286. icon: 'none',
  287. duration: 1000
  288. });
  289. return false;
  290. }
  291. if(this.parents.children) {
  292. for(let index in this.parents.children) {
  293. if(this.parents_two && this.parents_two.value == this.parents.children[index].value) {
  294. this.newIndex = +index;
  295. this.chooseIndex[0] = +index;
  296. }
  297. this.pickList.push(this.parents.children[index])
  298. }
  299. if(this.pickList.length == 0) {
  300. uni.showToast({
  301. title: '暂无二级分类',
  302. icon: 'none',
  303. duration: 1000
  304. });
  305. this.catItem.level--;
  306. return false;
  307. }
  308. this.$nextTick(() => {
  309. this.dialog = true;
  310. })
  311. }
  312. }
  313. if(type == 'ad') {
  314. this.pickList = this.linkList[this.chooseType];
  315. for(let index in this.linkList[this.chooseType]) {
  316. if(this.catItem.advert_url && this.catItem.advert_url == this.linkList[this.chooseType][index].value) {
  317. this.newIndex = +index;
  318. this.chooseIndex[0] = +index;
  319. }
  320. }
  321. this.$nextTick(() => {
  322. this.dialog = true;
  323. })
  324. }
  325. },
  326. submitChoose() {
  327. if(this.mode == 'one') {
  328. this.dialog = false;
  329. if(this.parents && this.parents.value != this.pickList[this.newIndex].value) {
  330. this.parents_two = null;
  331. }
  332. this.parents = this.pickList[this.newIndex];
  333. }else if(this.mode == 'two') {
  334. this.dialog = false;
  335. this.parents_two = this.pickList[this.newIndex];
  336. }else if(this.mode == 'ad') {
  337. if(this.pickList[this.newIndex].params) {
  338. this.params = this.pickList[this.newIndex].params;
  339. this.title = this.pickList[this.newIndex].name;
  340. this.showParams = true;
  341. }else {
  342. this.dialog = false;
  343. this.catItem.advert_url = this.pickList[this.newIndex].value;
  344. this.catItem.advert_open_type = this.pickList[this.newIndex].open_type;
  345. this.catItem.advert_params = [];
  346. }
  347. }
  348. },
  349. bindChange(e) {
  350. this.newIndex = +e.detail.value[0]
  351. },
  352. getCat() {
  353. let that = this;
  354. let url = this.mch_id == 0 ? that.$api.app_admin.cat : that.type == 'mall' ? that.$api.mch.cat : that.$api.mch.mch_cat;
  355. let para;
  356. that.$request({
  357. url: url,
  358. data: {
  359. mch_id: that.mch_id
  360. }
  361. }).then(response=>{
  362. that.$hideLoading();
  363. if(response.code == 0) {
  364. that.list = response.data.list;
  365. }else {
  366. uni.showToast({
  367. title: response.msg,
  368. icon: 'none',
  369. duration: 1000
  370. });
  371. }
  372. }).catch(response => {
  373. that.$hideLoading();
  374. });
  375. },
  376. getPickLine() {
  377. let that = this;
  378. that.$request({
  379. url: that.$api.app_admin.pick_link,
  380. }).then(response=>{
  381. that.$hideLoading();
  382. if(response.code == 0) {
  383. that.linkList = response.data.list;
  384. }else {
  385. uni.showToast({
  386. title: response.msg,
  387. icon: 'none',
  388. duration: 1000
  389. });
  390. }
  391. }).catch(response => {
  392. that.$hideLoading();
  393. });
  394. },
  395. add(name) {
  396. let that = this;
  397. this.menu = false;
  398. // #ifdef MP
  399. uni.chooseImage({
  400. count: 1,
  401. sizeType: ['original', 'compressed'],
  402. success(res) {
  403. // tempFilePath可以作为img标签的src属性显示图片
  404. const tempFilePaths = res.tempFilePaths;
  405. uni.showLoading({
  406. mask: true,
  407. title: '上传中...'
  408. });
  409. tempFilePaths.forEach(function (row, index) {
  410. let para = {
  411. pic_url: '',
  412. type: 'img',
  413. id: 0
  414. };
  415. let fileName = '';
  416. // #ifdef MP-BAIDU
  417. fileName = row.substr(row.lastIndexOf('/') + 1);
  418. // #endif
  419. uploadFile({
  420. url: that.$api.upload.file,
  421. filePath: row,
  422. fileType: 'image',
  423. mch_id: 0,
  424. fileName: fileName
  425. }).then(res => {
  426. uni.hideLoading();
  427. let imgInfo = undefined;
  428. // #ifndef MP-BAIDU
  429. imgInfo = JSON.parse(res.data);
  430. // #endif
  431. // #ifdef MP-BAIDU
  432. imgInfo = res.data;
  433. // #endif
  434. if (imgInfo.code == 0) {
  435. if(name == 'pic_url') {
  436. that.catItem.pic_url = imgInfo.data.url
  437. }else if(name == 'big_pic_url') {
  438. that.catItem.big_pic_url = imgInfo.data.url
  439. }else if(name == 'advert_pic') {
  440. that.catItem.advert_pic = imgInfo.data.url
  441. }
  442. }
  443. });
  444. })
  445. }
  446. })
  447. // #endif
  448. // #ifdef H5
  449. uni.chooseImage({
  450. count: 1,
  451. sizeType: ['original', 'compressed'],
  452. success: function(e) {
  453. uni.showLoading({
  454. mask: true,
  455. title: '上传中...'
  456. });
  457. let list = that.list;
  458. let image = new Image();
  459. image.src = e.tempFilePaths;
  460. let para = {
  461. pic_url: '',
  462. type: 'img',
  463. id: 0
  464. };
  465. image.onload = () => {
  466. let canvas = document.createElement("canvas");
  467. canvas.width = image.width;
  468. canvas.height = image.height;
  469. let ctx = canvas.getContext("2d");
  470. ctx.drawImage(image, 0, 0, image.width, image.height);
  471. let ext = image.src.substring(image.src.lastIndexOf(".") + 1).toLowerCase();
  472. let dataURL = canvas.toDataURL("image/" + ext);
  473. uploadFile({
  474. url: that.$api.upload.file,
  475. maxNum: 1,
  476. success: function({res, header}) {
  477. that.$request({
  478. url: that.$api.upload.file + '&name=base64',
  479. header: header,
  480. method: 'post',
  481. data: {
  482. database: dataURL
  483. }
  484. }).then(res => {
  485. uni.hideLoading();
  486. if (res.code === 0) {
  487. for(let i in list) {
  488. if(list[i].type === 'img' && list[i].pic_url === '') {
  489. list[i].pic_url = res.data.url;
  490. list[i].id = res.data.id;
  491. }
  492. }
  493. that.loadingImg = false;
  494. uni.hideLoading();
  495. } else {
  496. uni.showModal({
  497. title: '',
  498. content: res.msg,
  499. showCancel: false,
  500. });
  501. }
  502. })
  503. }
  504. });
  505. };
  506. }
  507. });
  508. // #endif
  509. },
  510. typeChange(e) {
  511. if(this.id > 0) return false;
  512. this.catItem.level = e.target.value;
  513. if(this.catItem.level == 3 && (this.parents &&!this.parents.children)) {
  514. this.parents = null;
  515. }
  516. },
  517. save() {
  518. let that = this;
  519. let url = this.mch_id == 0 ? that.$api.app_admin.cat_edit : that.type == 'mall' ? that.$api.mch.cat : that.$api.mch.mch_cat_edit;
  520. that.catItem.status = that.catItem.status.toString();
  521. if(that.catItem.level == 3) {
  522. if(that.parents_two && that.parents_two.value) {
  523. that.catItem.parent_id = that.parents_two.value
  524. }else {
  525. uni.showToast({
  526. title: '请选择归属的二级分类',
  527. icon: 'none',
  528. duration: 1000
  529. });
  530. return false;
  531. }
  532. }else if(that.catItem.level == 2) {
  533. if(that.parents && that.parents.value) {
  534. that.catItem.parent_id = that.parents.value
  535. }else {
  536. uni.showToast({
  537. title: '请选择归属的一级分类',
  538. icon: 'none',
  539. duration: 1000
  540. });
  541. return false;
  542. }
  543. }
  544. if(!that.catItem.name) {
  545. uni.showToast({
  546. title: '分类名称不能为空',
  547. icon: 'none',
  548. duration: 1000
  549. });
  550. return false;
  551. }
  552. uni.showLoading({
  553. mask: true,
  554. title: '提交中...'
  555. });
  556. if(that.mch_id > 0) {
  557. that.catItem.mch_id = that.mch_id;
  558. }
  559. that.catItem.is_show = +that.catItem.is_show;
  560. that.catItem.status = that.catItem.status.toString();
  561. that.$request({
  562. url: url,
  563. data: {
  564. form: JSON.stringify(that.catItem),
  565. mch_id: that.mch_id
  566. },
  567. method: 'post'
  568. }).then(response=>{
  569. that.$hideLoading();
  570. uni.hideLoading();
  571. if(response.code == 0) {
  572. uni.showToast({
  573. title: response.msg,
  574. duration: 1000
  575. });
  576. setTimeout(()=>{
  577. uni.navigateBack();
  578. },1000)
  579. }else {
  580. uni.showToast({
  581. title: response.msg,
  582. icon: 'none',
  583. duration: 1000
  584. });
  585. }
  586. }).catch(response => {
  587. uni.hideLoading();
  588. that.$hideLoading();
  589. });
  590. },
  591. getDetail() {
  592. let that = this;
  593. let url = this.mch_id == 0 ? that.$api.app_admin.cat_edit : that.type == 'mall' ? that.$api.mch.cat : that.$api.mch.mch_cat_edit;
  594. let para;
  595. that.$request({
  596. url: url,
  597. data: {
  598. id: that.id,
  599. mch_id: that.mch_id
  600. }
  601. }).then(response=>{
  602. that.$hideLoading();
  603. if(response.code == 0) {
  604. that.catItem = response.data.detail;
  605. that.catItem.level = response.data.detail.parents.length + 1;
  606. if(that.catItem.level > 1) {
  607. for(let item of that.catItem.parents) {
  608. if(item.parent_id == 0) {
  609. that.parents = {
  610. label: item.name,
  611. value: item.id
  612. };
  613. }else {
  614. that.parents_two = {
  615. label: item.name,
  616. value: item.id
  617. };
  618. }
  619. }
  620. }
  621. }else {
  622. uni.showToast({
  623. title: response.msg,
  624. icon: 'none',
  625. duration: 1000
  626. });
  627. }
  628. }).catch(response => {
  629. that.$hideLoading();
  630. });
  631. },
  632. },
  633. onLoad(options) {
  634. let that = this;
  635. this.id = options.id ? options.id : 0;
  636. this.type = options.type ? options.type : '';
  637. this.mch_id = options.mch_id ? options.mch_id : 0;
  638. this.color = this.mch_id > 0 ? '#ff4544' : '#446dfd';
  639. uni.setNavigationBarTitle({
  640. title: this.id > 0 ? '编辑分类' : '新增分类'
  641. });
  642. if(this.mch_id == 0) that.getPickLine();
  643. if(this.id > 0) {
  644. that.$showLoading({
  645. type: 'global',
  646. text: '加载中...'
  647. });
  648. this.getDetail();
  649. }
  650. uni.getSystemInfo({
  651. success: function (res) {
  652. if(res.model.indexOf('iPhone X') > -1 || res.model.indexOf('iPhone 11') > -1 || res.model.indexOf('iPhone11') > -1 || res.model.indexOf('iPhone12') > -1 || res.model.indexOf('Unknown Device') > -1) {
  653. that.iphone_x = true;
  654. }
  655. }
  656. })
  657. that.getCat();
  658. }
  659. }
  660. </script>
  661. <style scoped lang="scss">
  662. .cat-info {
  663. background-color: #fff;
  664. padding: 0 #{24rpx};
  665. .cat-item:first-of-type {
  666. border-top: 0;
  667. }
  668. .select {
  669. width: 100%;
  670. }
  671. .form-label {
  672. padding: 30rpx 0;
  673. width: #{148rpx};
  674. text-align: right;
  675. margin-right: 16rpx;
  676. flex-shrink: 0;
  677. .sub-label {
  678. font-size: 24rpx;
  679. color: #999999;
  680. }
  681. }
  682. .price-input {
  683. width: 100%;
  684. input {
  685. width: 100%;
  686. }
  687. }
  688. .cat-item {
  689. border-top: #{1rpx} solid #e2e2e2;
  690. min-height: #{88rpx};
  691. font-size: #{28rpx};
  692. color: #353535;
  693. .to-more {
  694. height: #{24rpx};
  695. width: #{12rpx};
  696. margin-left: #{10rpx};
  697. }
  698. .cat-pic {
  699. width: 80rpx;
  700. height: 80rpx;
  701. margin-right: 28rpx;
  702. &.big {
  703. width: 265rpx;
  704. }
  705. &.advert {
  706. width: 218rpx;
  707. }
  708. }
  709. }
  710. }
  711. .cat {
  712. background-color: #fff;
  713. margin-bottom: #{20rpx};
  714. .show-more {
  715. width: 45rpx;
  716. height: 88rpx;
  717. image {
  718. height: #{22rpx};
  719. width: #{12rpx};
  720. }
  721. }
  722. .cat-item {
  723. height: #{88rpx};
  724. line-height: #{88rpx};
  725. font-size: #{28rpx};
  726. color: #353535;
  727. &.cat-left {
  728. margin-left: 16rpx;
  729. }
  730. }
  731. .cat-menu {
  732. margin-right: 16rpx;
  733. image {
  734. height: #{40rpx};
  735. width: #{40rpx};
  736. margin-left: 10rpx;
  737. }
  738. }
  739. }
  740. .add {
  741. position: fixed;
  742. bottom: 0;
  743. left: 0;
  744. height: #{120rpx};
  745. width: 100%;
  746. z-index: 15;
  747. background-color: #fff;
  748. &.iphone_x {
  749. height: #{170rpx};
  750. padding-bottom: #{50rpx};
  751. }
  752. view {
  753. width: #{702rpx};
  754. line-height: #{80rpx};
  755. height: #{80rpx};
  756. margin: #{20rpx} auto;
  757. border-radius: #{40rpx};
  758. background-color: #446dfd;
  759. color: #fff;
  760. font-size: #{32rpx};
  761. text-align: center;
  762. }
  763. }
  764. .placeholder {
  765. height: #{120rpx};
  766. &.iphone_x {
  767. height: #{170rpx};
  768. }
  769. }
  770. .params-dialog {
  771. position: fixed;
  772. height: 100%;
  773. width: 100%;
  774. bottom: 0;
  775. left: 0;
  776. z-index: 22;
  777. background-color: rgba(0, 0, 0, .3);
  778. .params {
  779. width: #{620rpx};
  780. background-color: white;
  781. border-radius: #{16rpx};
  782. margin-top: #{-200rpx};
  783. .params-title {
  784. margin: #{40rpx} 0;
  785. font-size: #{32rpx};
  786. color: #353535;
  787. text-align: center;
  788. }
  789. .params-list {
  790. max-height: #{480rpx};
  791. overflow-y: auto;
  792. .params-item {
  793. margin-bottom: #{20rpx};
  794. .params-label {
  795. height:#{80rpx};
  796. line-height: #{80rpx};
  797. margin-right: #{20rpx};
  798. }
  799. .params-input {
  800. height:#{80rpx};
  801. line-height: #{80rpx};
  802. background-color: #f7f7f7;
  803. border-radius: #{8rpx};
  804. width: #{320rpx};
  805. padding: #{0 28rpx};
  806. box-sizing: border-box;
  807. text-align: left;
  808. input {
  809. width: 100%;
  810. height: 100%;
  811. }
  812. }
  813. .params-desc {
  814. margin-top: #{10rpx};
  815. padding: 0 #{24rpx};
  816. color: #999;
  817. font-size: #{28rpx};
  818. text-align: center;
  819. }
  820. }
  821. }
  822. .params-buttons {
  823. width: #{620rpx};
  824. height: #{88rpx};
  825. border-top: #{1rpx} solid #e2e2e2;
  826. .line {
  827. width: #{2rpx};
  828. height: #{32rpx};
  829. background-color: #e2e2e2;
  830. }
  831. .but {
  832. width: #{309rpx};
  833. height: #{88rpx};
  834. line-height: #{88rpx};
  835. text-align: center;
  836. font-size: #{32rpx};
  837. }
  838. .cancel {
  839. color: #{32rpx};
  840. }
  841. .confirm {
  842. color: #446dfd;
  843. }
  844. }
  845. }
  846. }
  847. .dialog {
  848. position: fixed;
  849. height: 100%;
  850. width: 100%;
  851. bottom: 0;
  852. left: 0;
  853. z-index: 20;
  854. background-color: rgba(0, 0, 0, .3);
  855. .picker-list {
  856. background-color: #fff;
  857. padding-top: #{20rpx};
  858. position: fixed;
  859. bottom: 0;
  860. left: 0;
  861. width: 100%;
  862. .picker-type {
  863. height: 84rpx;
  864. border-bottom: 2rpx solid #e2e2e2;
  865. padding: 0 24rpx;
  866. .picker-type-item {
  867. height: 82rpx;
  868. line-height: 82rpx;
  869. text-align: center;
  870. font-size: 28rpx;
  871. &.active {
  872. border-bottom: 3rpx solid;
  873. }
  874. }
  875. }
  876. .picker-header {
  877. padding: 0 #{24rpx};
  878. font-size: #{32rpx};
  879. }
  880. .picker {
  881. width: 100%;
  882. height: #{440rpx};
  883. color: #999999;
  884. }
  885. .picker-text {
  886. height: 34px;
  887. line-height: 34px;
  888. font-size: #{32rpx};
  889. padding-left: #{24rpx};
  890. text-align: left;
  891. }
  892. }
  893. }
  894. </style>