addPartner.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="content">
  6. <view class="cell flex flex-y-center">
  7. <view class="title-block required">
  8. <text>等级</text>
  9. </view>
  10. <view class="desc">
  11. <input type="number" maxlength="3" :value="info.shared_level?info.shared_level:1"
  12. name="shared_level" class="input-box" placeholder="请输入等级"
  13. placeholder-class="desc-placeholder">
  14. </view>
  15. <view class="red">数字越大等级越高</view>
  16. </view>
  17. <view class="cell flex flex-y-center">
  18. <view class="title-block required">
  19. <text>等级名称</text>
  20. </view>
  21. <view class="desc">
  22. <input type="text" :value="info.name" name="name" class="input-box" placeholder="请输入等级名称"
  23. placeholder-class="desc-placeholder">
  24. </view>
  25. </view>
  26. <view class="cell flex flex-y-center">
  27. <view class="title-block required">
  28. <text>进阶费用</text>
  29. </view>
  30. <view class="desc">
  31. <input type="digit" :value="info.amount" name="amount" class="input-box"
  32. placeholder="请输入进阶费用" placeholder-class="desc-placeholder">
  33. </view>
  34. </view>
  35. <view class="cell flex flex-y-center">
  36. <view class="title-block required">
  37. <text>缴纳费用</text>
  38. </view>
  39. <view class="desc">
  40. <input type="digit" :value="info.money" name="money" class="input-box" placeholder="请输入缴纳费用"
  41. placeholder-class="desc-placeholder">
  42. </view>
  43. </view>
  44. <view class="cell flex flex-y-center">
  45. <view class="title-block required">
  46. <text>直接佣金比例(%)</text>
  47. </view>
  48. <view class="desc">
  49. <input type="digit" :value="info.direct_commission" name="direct_commission"
  50. class="input-box" placeholder="请输入直接佣金比例" placeholder-class="desc-placeholder">
  51. </view>
  52. </view>
  53. <view class="red">直接+间接比例不能超100%</view>
  54. <view class="cell flex flex-y-center">
  55. <view class="title-block required">
  56. <text>间接佣金比例(%)</text>
  57. </view>
  58. <view class="desc">
  59. <input type="digit" :value="info.indirect_commission" name="indirect_commission"
  60. class="input-box" placeholder="请输入间接佣金比例" placeholder-class="desc-placeholder">
  61. </view>
  62. </view>
  63. <view class="red">直接+间接比例不能超100%</view>
  64. <view class="cell flex flex-y-center">
  65. <view class="title-block required">
  66. <text>上架开关</text>
  67. </view>
  68. <view class="desc">
  69. <view class="flex-center">
  70. <view class="checklist-box " @click="chooseSwicth(index)"
  71. v-for="(item,index) of sjSwitch" :key='index'
  72. :class="sjSwitchIndex==index?'actt':''">
  73. <view class="radio__inner" :class="sjSwitchIndex==index?'act_border':''">
  74. <view :class="sjSwitchIndex==index?'is-default-checked':''"
  75. class="radio__inner-icon radio__inner-icon ">
  76. </view>
  77. </view>
  78. <text class="checklist-text">{{item}}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="cell flex flex-y-center">
  84. <view class="title-block required">
  85. <text>显示位置</text>
  86. </view>
  87. <view class="desc">
  88. <view class="flex-center">
  89. <view class="checklist-box " @click="chooseShowStatus(index)"
  90. v-for="(item,index) of show_arr" :key='index' :class="showIndex==index?'actt':''">
  91. <view class="radio__inner" :class="showIndex==index?'act_border':''">
  92. <view :class="showIndex==index?'is-default-checked':''"
  93. class="radio__inner-icon radio__inner-icon ">
  94. </view>
  95. </view>
  96. <text class="checklist-text">{{item}}</text>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="cell flex flex-y-center">
  102. <view class="title-block required">
  103. <text>礼盒数量</text>
  104. </view>
  105. <view class="desc">
  106. <input type="digit" :value="info.gift" name="gift" class="input-box" placeholder="请输入礼盒数量"
  107. placeholder-class="desc-placeholder">
  108. </view>
  109. </view>
  110. <view class="red">成为合伙人以后的礼盒数量</view>
  111. <view class="cell flex flex-y-center">
  112. <view class="title-block required">
  113. <text>直升会员等级</text>
  114. </view>
  115. <view class="desc">
  116. <picker mode="selector" :range="tableTypeList" range-key="name"
  117. @change="onTableTypeChange(0,$event)">
  118. <view class="box-pack-between">
  119. <text>
  120. <block v-if="ClassIndex == -1">请选择直升会员等级</block>
  121. <block v-else>{{tableTypeList[ClassIndex].name}}</block>
  122. </text>
  123. <text class="iconfont icongengduo"></text>
  124. </view>
  125. </picker>
  126. </view>
  127. </view>
  128. <view class="red">购买此礼包后可直接成为此会员等级</view>
  129. <view class="cell flex flex-y-center">
  130. <view class="title-block required">
  131. <text>赠送积分</text>
  132. </view>
  133. <view class="desc">
  134. <input type="digit" :value="info.integral" name="integral" class="input-box"
  135. placeholder="请输入赠送积分" placeholder-class="desc-placeholder">
  136. </view>
  137. </view>
  138. <view class="red">成为合伙人以后赠送的积分</view>
  139. <view class="cell flex flex-y-center">
  140. <view class="title-block required">
  141. <text>赠送余额</text>
  142. </view>
  143. <view class="desc">
  144. <input type="digit" :value="info.balance" name="balance" class="input-box"
  145. placeholder="请输入赠送余额" placeholder-class="desc-placeholder">
  146. </view>
  147. </view>
  148. <view class="red">成为合伙人以后赠送的余额</view>
  149. <view style="padding: 25rpx 0;">
  150. <view class="title" style="color: blue;">以下为分享礼盒的设置</view>
  151. </view>
  152. <view class="cell flex flex-y-center">
  153. <view class="title-block required">
  154. <text>直升会员</text>
  155. </view>
  156. <view class="desc">
  157. <picker mode="selector" :range="tableTypeList" range-key="name"
  158. @change="onTableTypeChange(1,$event)">
  159. <view class="box-pack-between">
  160. <text>
  161. <block v-if="ClassIndexTwo == -1">请选择直升会员</block>
  162. <block v-else>{{tableTypeList[ClassIndexTwo].name}}</block>
  163. </text>
  164. <text class="iconfont icongengduo"></text>
  165. </view>
  166. </picker>
  167. </view>
  168. </view>
  169. <view class="cell flex flex-y-center">
  170. <view class="title-block required">
  171. <text>赠送积分</text>
  172. </view>
  173. <view class="desc">
  174. <input type="digit" :value="info.share_intrgral" name="share_intrgral" class="input-box"
  175. placeholder="请输入赠送积分" placeholder-class="desc-placeholder">
  176. </view>
  177. </view>
  178. <view class="cell flex flex-y-center">
  179. <view class="title-block required">
  180. <text>礼盒数量</text>
  181. </view>
  182. <view class="desc">
  183. <input type="digit" :value="info.share_gift" name="share_gift" class="input-box"
  184. placeholder="请输入礼盒数量" placeholder-class="desc-placeholder">
  185. </view>
  186. </view>
  187. <view class="cell flex flex-y-center">
  188. <view class="title-block">
  189. <text>礼盒描述</text>
  190. </view>
  191. <view class="desc">
  192. <textarea :value="info.gitf_content" maxlength="500" name="gitf_content"
  193. class="giftDescribe" placeholder="请输入礼盒描述" placeholder-class="desc-placeholder" />
  194. </view>
  195. </view>
  196. </view>
  197. </view>
  198. <view class="footer-bar" style="z-index: 999;">
  199. <view class="content flex flex-center" style="background: none;">
  200. <button class="btn" hover-class="none" form-type="submit">
  201. {{id?'立即修改':'立即添加'}}
  202. </button>
  203. </view>
  204. </view>
  205. </form>
  206. </view>
  207. </template>
  208. <script>
  209. export default {
  210. data() {
  211. return {
  212. sjSwitch: [
  213. '启用', '禁用'
  214. ],
  215. sjSwitchIndex: -1, //上架开关
  216. show_arr: [
  217. '仅微信', '仅支付宝', '微信和支付宝'
  218. ],
  219. showIndex: -1, //显示位置
  220. ClassIndex: -1, //直升会员等级索引
  221. ClassIndexTwo: -1, //直升会员索引
  222. id: "",
  223. info: {},
  224. tableTypeList: [],
  225. admin_id: '',
  226. pageType: '', //页面类型1是列表进入的2是详情进入
  227. }
  228. },
  229. onLoad(e) {
  230. this.admin_id = uni.getStorageSync("admin_id");
  231. this.id = e.id ? e.id : '';
  232. uni.setNavigationBarTitle({
  233. title: e.id ? '编辑合伙人等级' : '添加合伙人等级'
  234. })
  235. this.shop_store_index();
  236. },
  237. methods: {
  238. //上架开关
  239. chooseSwicth(index) {
  240. this.sjSwitchIndex = index
  241. },
  242. //选择显示方式
  243. chooseShowStatus(index) {
  244. this.showIndex = index
  245. },
  246. //会员等级列表
  247. shop_store_index() {
  248. this.request({
  249. url: 'smdcshop/user_level',
  250. data: {
  251. admin_id: this.admin_id,
  252. }
  253. }).then(res => {
  254. if (res.code == 200) {
  255. this.tableTypeList = res.data;
  256. if (this.id) {
  257. this.getData(this.id)
  258. }
  259. }
  260. })
  261. },
  262. //选择直升会员以及等级
  263. onTableTypeChange(index, e) {
  264. if (index == 0) {
  265. this.ClassIndex = e.detail.value;
  266. } else {
  267. this.ClassIndexTwo = e.detail.value;
  268. }
  269. },
  270. getData(id) {
  271. this.request({
  272. url: 'smdcshop/shared_level_info',
  273. data: {
  274. id
  275. }
  276. }).then(res => {
  277. if (res.code == "200") {
  278. this.info = res.data;
  279. this.sjSwitchIndex = Number(res.data.status) - 1;
  280. this.showIndex = Number(res.data.location) - 1;
  281. let classList = this.tableTypeList;
  282. if (classList.length > 0) {
  283. for (let i = 0; i < classList.length; i++) {
  284. console.log(classList[i])
  285. if (classList[i].id == res.data.level) {
  286. this.ClassIndex = i;
  287. }
  288. if (classList[i].id == res.data.share_level) {
  289. this.ClassIndexTwo = i;
  290. }
  291. }
  292. }
  293. }
  294. })
  295. },
  296. onSubmit(e) {
  297. let pages = getCurrentPages();
  298. let prevPage = pages[pages.length - 2]; //上级页面
  299. let zsClass = this.ClassIndex; //直升会员等级索引
  300. let zsClassTwo = this.ClassIndexTwo; //直升会员索引
  301. let params = e.detail.value;
  302. params.admin_id = this.admin_id ? this.admin_id : '';
  303. params.id = this.id ? this.id : '';
  304. params.status = Number(this.sjSwitchIndex) + 1;
  305. params.location = Number(this.showIndex) + 1;
  306. params.level = zsClass == -1 ? '' : this.tableTypeList[zsClass].id;
  307. params.share_level = zsClassTwo == -1 ? '' : this.tableTypeList[zsClassTwo].id;
  308. if (!params.shared_level) {
  309. uni.showToast({
  310. title: "请填写等级",
  311. icon: 'none'
  312. })
  313. return false
  314. }
  315. if (!params.name) {
  316. uni.showToast({
  317. title: "请填写等级名称",
  318. icon: 'none'
  319. })
  320. return false
  321. }
  322. if (!params.amount) {
  323. uni.showToast({
  324. title: "请填写进阶费用",
  325. icon: 'none'
  326. })
  327. return false
  328. }
  329. if (!params.money) {
  330. uni.showToast({
  331. title: "请填写缴纳费用",
  332. icon: 'none'
  333. })
  334. return false
  335. }
  336. if (!params.direct_commission) {
  337. uni.showToast({
  338. title: "请填写直接佣金比例",
  339. icon: 'none'
  340. })
  341. return false
  342. }
  343. if (!params.indirect_commission) {
  344. uni.showToast({
  345. title: "请填写间接佣金比例",
  346. icon: 'none'
  347. })
  348. return false
  349. }
  350. if (Number(params.direct_commission) + Number(params.indirect_commission) > 100) {
  351. uni.showToast({
  352. title: "直接+间接比例不能超100%",
  353. icon: 'none'
  354. })
  355. return false
  356. }
  357. if (this.sjSwitchIndex == -1) {
  358. uni.showToast({
  359. title: "请选择上架开关",
  360. icon: 'none'
  361. })
  362. return false
  363. }
  364. if (this.showIndex == -1) {
  365. uni.showToast({
  366. title: "请选择显示位置",
  367. icon: 'none'
  368. })
  369. return false
  370. }
  371. if (!params.gift) {
  372. uni.showToast({
  373. title: "请填写礼盒数量",
  374. icon: 'none'
  375. })
  376. return false
  377. }
  378. if (this.ClassIndex == -1) {
  379. uni.showToast({
  380. title: "请选择直升会员等级",
  381. icon: 'none'
  382. })
  383. return false
  384. }
  385. if (!params.integral) {
  386. uni.showToast({
  387. title: "请填写赠送积分",
  388. icon: 'none'
  389. })
  390. return false
  391. }
  392. if (!params.balance) {
  393. uni.showToast({
  394. title: "请填写赠送余额",
  395. icon: 'none'
  396. })
  397. return false
  398. }
  399. if (this.ClassIndexTwo == -1) {
  400. uni.showToast({
  401. title: "请选择直升会员",
  402. icon: 'none'
  403. })
  404. return false
  405. }
  406. if (!params.share_intrgral) {
  407. uni.showToast({
  408. title: "请填写赠送积分",
  409. icon: 'none'
  410. })
  411. return false
  412. }
  413. if (!params.share_gift) {
  414. uni.showToast({
  415. title: "请填写礼盒数量",
  416. icon: 'none'
  417. })
  418. return false
  419. }
  420. this.request({
  421. url: 'smdcshop/level_save',
  422. data: params
  423. }).then(res => {
  424. if (res.code == 200) {
  425. uni.showToast({
  426. title: res.message,
  427. icon: 'none'
  428. })
  429. prevPage.__data__.page = 1;
  430. prevPage.__data__.list = [];
  431. prevPage.$vm.getData(1)
  432. setTimeout(() => {
  433. uni.navigateBack()
  434. }, 2000)
  435. }
  436. }).catch((res) => {
  437. uni.showToast({
  438. title: res.message,
  439. icon: 'none'
  440. })
  441. });
  442. },
  443. }
  444. }
  445. </script>
  446. <style>
  447. @import url("../static/css/common.css");
  448. page {
  449. background-color: #F4F5F7;
  450. }
  451. .checklist-box {
  452. display: -webkit-box;
  453. display: -webkit-flex;
  454. display: flex;
  455. -webkit-box-orient: horizontal;
  456. -webkit-box-direction: normal;
  457. -webkit-flex-direction: row;
  458. flex-direction: row;
  459. -webkit-box-align: center;
  460. -webkit-align-items: center;
  461. align-items: center;
  462. margin: 5px 0;
  463. margin-right: 22px;
  464. }
  465. .radio__inner {
  466. -webkit-flex-shrink: 0;
  467. flex-shrink: 0;
  468. display: -webkit-box;
  469. display: -webkit-flex;
  470. display: flex;
  471. -webkit-box-pack: center;
  472. -webkit-justify-content: center;
  473. justify-content: center;
  474. -webkit-box-align: center;
  475. -webkit-align-items: center;
  476. align-items: center;
  477. position: relative;
  478. border: 1px solid #DCDFE6;
  479. border-radius: 2px;
  480. box-sizing: border-box;
  481. width: 16px;
  482. height: 16px;
  483. border-radius: 16px;
  484. background-color: #fff;
  485. z-index: 1;
  486. -webkit-transition: border-color .3s;
  487. transition: border-color .3s;
  488. }
  489. .radio__inner-icon {
  490. width: 8px;
  491. height: 8px;
  492. border-radius: 10px;
  493. opacity: 0;
  494. -webkit-transition: -webkit-transform .3s;
  495. transition: -webkit-transform .3s;
  496. transition: transform .3s;
  497. transition: transform .3s, -webkit-transform .3s;
  498. }
  499. .is-default-checked {
  500. opacity: 1;
  501. background-color: #007aff;
  502. -webkit-transform: rotate(45deg) scaleY(1);
  503. transform: rotate(45deg) scaleY(1);
  504. }
  505. .checklist-text {
  506. font-size: 28rpx;
  507. margin-left: 5px;
  508. -webkit-transition: color 0.2s;
  509. transition: color 0.2s;
  510. color: #000;
  511. }
  512. .act_border {
  513. border: 1rpx solid #007aff;
  514. }
  515. .giftDescribe {
  516. width: 100%;
  517. padding: 30rpx;
  518. }
  519. .red {
  520. color: red;
  521. padding: 10rpx 25rpx;
  522. font-size: 26rpx;
  523. }
  524. </style>