register_3.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <u-form :model="form" ref="uForm">
  4. <u-card :border="false" padding="30" box-shadow="0px 1px 10px rgba(0,0,0,0.2)" border-radius="20" :show-foot="false">
  5. <view slot="head">
  6. <view class="u-flex">
  7. <view style="width: 8rpx;height: 34rpx;background: #0292FD;margin-right:20rpx;"></view>
  8. 选择合作品牌
  9. </view>
  10. </view>
  11. <view slot="body">
  12. <u-form-item prop="cooperation">
  13. <view style="margin-right: 10rpx;">
  14. <u-icon name="order" size="36"></u-icon>
  15. </view>
  16. <u-input placeholder="点击选择合作品牌" :disabled="true" @click="brandShow = true;" v-model="form.cooperation"></u-input>
  17. <view class="" slot="right">
  18. <u-icon name="arrow-right" color="#666666" size="36"></u-icon>
  19. </view>
  20. </u-form-item>
  21. </view>
  22. </u-card>
  23. <u-popup mode="bottom" v-model="brandShow">
  24. <view class="u-flex u-row-between u-padding-left-40 u-padding-right-40" style="height: 90rpx;" @click="show = false;">
  25. <view style="padding: 16rpx;font-size:30rpx" @click="brandShow=false">
  26. 取消
  27. </view>
  28. <view style="padding: 16rpx;color:#0095FF;font-size:30rpx" @click="getCooperation">
  29. 确认
  30. </view>
  31. </view>
  32. <u-line color="#e4e7ed"></u-line>
  33. <view class="content">
  34. <u-checkbox-group :wrap="true" @change="checkboxGroupChange" style="display: flex;justify-content: left">
  35. <u-checkbox v-model="item.checked" v-for="(item, index) in allbrandList" :key="index" :name="item.brandCode"
  36. shape="circle">
  37. <view class="u-flex u-row-left" style="width: 150rpx;">
  38. {{item.brandCode}}
  39. </view>
  40. </u-checkbox>
  41. </u-checkbox-group>
  42. </view>
  43. </u-popup>
  44. <u-card v-if="this.form.cooperation.length" :border="false" padding="30" box-shadow="0px 1px 10px rgba(0,0,0,0.2)"
  45. border-radius="20" :show-foot="false">
  46. <view slot="head">
  47. <view class="u-flex">
  48. <view style="width: 8rpx;height: 34rpx;background: #0292FD;margin-right:20rpx;"></view>
  49. 已选合作品牌
  50. </view>
  51. </view>
  52. <view slot="body" style="display:flex;width:100%;flex-flow: wrap;justify-content: space-around;align-items: center;">
  53. <view v-for="(item,index) in querybrandList" :key="index" style="width: 250rpx;">
  54. <u-image width="250rpx" :src="item.logUrl" mode="widthFix"></u-image>
  55. </view>
  56. </view>
  57. </u-card>
  58. <u-card :border="false" padding="30" box-shadow="0px 1px 10px rgba(0,0,0,0.2)" border-radius="20" :show-foot="false"
  59. v-for="(item, index) in checkedAgentlist" :key="index">
  60. <view slot="head">
  61. <view class="u-flex u-row-between">
  62. <view class="u-flex">
  63. <view style="width: 8rpx;height: 34rpx;background: #0292FD;margin-right:20rpx;"></view>
  64. {{item.brand}}合作品牌签约任务
  65. </view>
  66. <view @click="delAgent(index)">
  67. <u-icon name="close" color="#666666" size="36"></u-icon>
  68. </view>
  69. </view>
  70. </view>
  71. <view slot="body">
  72. <u-form-item>
  73. <view style="margin-right: 10rpx;">
  74. <u-icon name="account" size="36"></u-icon>
  75. </view>
  76. <view class="">
  77. {{item.name}}
  78. </view>
  79. </u-form-item>
  80. <u-form-item prop="taskNum">
  81. <view style="margin-right: 10rpx;">
  82. <u-icon name="order" size="36"></u-icon>
  83. </view>
  84. <u-radio-group v-model="item.taskNum" :disabled="item.disabledGroup" @change="changeRadiogroup(item)">
  85. <u-radio @click.native.prevent="clickitem(item,i.signLv)" :label-disabled="i.labelDisabled" v-for="(i, index2) in tasknameList"
  86. :key="index2" :name="i.signLv">
  87. {{i.signLv}}
  88. </u-radio>
  89. </u-radio-group>
  90. </u-form-item>
  91. </view>
  92. </u-card>
  93. <u-card v-if="checkedAgentlist.length==0&&this.form.cooperation.length" :border="false" padding="30" box-shadow="0px 1px 10px rgba(0,0,0,0.2)"
  94. border-radius="20" :show-foot="false">
  95. <view slot="head">
  96. <view class="u-flex">
  97. <view style="width: 8rpx;height: 34rpx;background: #0292FD;margin-right:20rpx;"></view>
  98. 温馨提示
  99. </view>
  100. </view>
  101. <view slot="body" style="display:flex;width:100%;flex-flow: wrap;justify-content: space-around;align-items: center;">
  102. 此地区暂无此品牌的经销商
  103. </view>
  104. </u-card>
  105. <u-form-item :border-bottom="false">
  106. <view style="margin:0 30rpx;">
  107. <u-checkbox-group>
  108. <u-checkbox v-model="protocol">同意《用户协议》及《隐私政策》</u-checkbox>
  109. </u-checkbox-group>
  110. </view>
  111. </u-form-item>
  112. </u-form>
  113. <view style="margin:0 30rpx;">
  114. <u-button @click="nextStep" type="primary" @tap="$u.debounce(submit, 2000,immediate = true)" :loading="loading"
  115. :ripple="true" ripple-bg-color="#99d4ff">确认注册</u-button>
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. import {
  121. request
  122. } from '../../common/request/request'
  123. require("promise.prototype.finally").shim()
  124. export default {
  125. data() {
  126. return {
  127. brandShow: false,
  128. loading: false,
  129. form: {
  130. cooperation: '',
  131. },
  132. formData: '',
  133. dataUrl: '',
  134. agentList: [], //经销商信息
  135. checkedAgentlist: [],
  136. taskList: [],
  137. tasknameList: [],
  138. brandAgentLvQueryList: [],
  139. rules: {
  140. cooperation: [{
  141. required: true,
  142. message: '请选择品牌',
  143. trigger: 'blur,change'
  144. }]
  145. },
  146. protocol: false,
  147. querybrandList: [],
  148. // brandList: [],
  149. allbrandList: [], //弹出窗获取brand数组
  150. checkedBrandlist: [] //选中brand组成一个新数组
  151. }
  152. },
  153. created() {
  154. uni.$on('formData', (data) => {
  155. this.formData = data.formData
  156. this.dataUrl = data.dataUrl
  157. })
  158. },
  159. mounted() {
  160. this.getAgentArea()
  161. this.getTasknum()
  162. this.getAllbrandlist()
  163. },
  164. methods: {
  165. getAgentArea() {
  166. uni.showLoading({
  167. title: '加载中...'
  168. });
  169. request({
  170. url: '/sailun/appStoreBasicInfo/getAgentArea',
  171. method: 'post',
  172. data: {
  173. "area": this.formData.district,
  174. "city": this.formData.city,
  175. "province": this.formData.province,
  176. // "area": "李沧区",
  177. // "city": "青岛市",
  178. // "province": "山东省",
  179. "spart": "10",
  180. "vkorg": "8100",
  181. "vtweg": "10"
  182. }
  183. }).then(res => {
  184. if (res.data.code == 0) {
  185. this.agentList = res.data.Data.data
  186. this.agentList = this.agentList.reduce((res, item, index, array) => {
  187. for (let i = 0; i < array[index].regionBrandList.length; i++) {
  188. res.push({
  189. brand: array[index].regionBrandList[i],
  190. brandCode: array[index].regionBrandList[i],
  191. name: item.name,
  192. kunnr: item.kunnr,
  193. agent_id: item.kunnr,
  194. taskNum: "",
  195. disabledGroup: false,
  196. checked: false,
  197. })
  198. }
  199. return res;
  200. }, []);
  201. // this.brandList = [...new Set(this.agentList.reduce((res, item, index, array) => {
  202. // res.push(item.brand)
  203. // return res;
  204. // }, []))].reduce((res, item, index, array) => {
  205. // res.push({
  206. // brand: item
  207. // })
  208. // return res;
  209. // }, []);
  210. }
  211. if (res.data.code == 500) {
  212. this.$u.toast(res.data.msg);
  213. }
  214. return this.agentList
  215. }).catch(err => {
  216. console.log(err)
  217. }).finally(() => {
  218. uni.hideLoading()
  219. })
  220. },
  221. getAllbrandlist() {
  222. request({
  223. url: '/sailun/appStoreBasicInfo/queryBrand',
  224. method: 'get',
  225. data: {},
  226. }).then(res => {
  227. if (res.data.code == 0) {
  228. this.allbrandList = res.data.data
  229. }
  230. if (res.data.code == 500) {
  231. this.$u.toast(res.data.msg);
  232. }
  233. }).catch(err => {
  234. console.log(err)
  235. }).finally(() => {
  236. })
  237. },
  238. getQuerybrand() {
  239. request({
  240. url: '/sailun/appStoreBasicInfo/queryBrand',
  241. method: 'get',
  242. data: {},
  243. }).then(res => {
  244. if (res.data.code == 0) {
  245. this.querybrandList = res.data.data
  246. this.querybrandList = this.querybrandList.filter(item => this.checkedBrandlist.indexOf(item.brandCode) > -1)
  247. }
  248. if (res.data.code == 500) {
  249. this.$u.toast(res.data.msg);
  250. }
  251. }).catch(err => {
  252. console.log(err)
  253. }).finally(() => {
  254. })
  255. },
  256. getTasknum() {
  257. request({
  258. url: '/sailun/appStoreBasicInfo/enum',
  259. method: 'get',
  260. data: {},
  261. }).then(res => {
  262. if (res.data.code == 0) {
  263. res.data.data.map((item, index) => {
  264. item.checked = false;
  265. })
  266. this.tasknameList = res.data.data
  267. }
  268. if (res.data.code == 500) {
  269. this.$u.toast(res.data.msg);
  270. }
  271. }).catch(err => {
  272. console.log(err)
  273. }).finally(() => {
  274. })
  275. },
  276. checkboxGroupChange(e) {
  277. this.cooperations = e
  278. },
  279. changeRadiogroup(item) {
  280. if (item.checked == true) {
  281. this.checkedAgentlist.filter(e => (e.brand === item.brand && e.agent_id != item.agent_id)).forEach(e => e.disabledGroup =
  282. false)
  283. } else {
  284. this.checkedAgentlist.filter(e => (e.brand === item.brand && e.agent_id != item.agent_id)).forEach(e => e.disabledGroup =
  285. true)
  286. }
  287. },
  288. clickitem(item, e) {
  289. if (item.checked == false) {
  290. item.checked = true
  291. } else {
  292. item.checked = false
  293. item.taskNum = ""
  294. }
  295. },
  296. getCooperation() {
  297. if (this.cooperations != null) {
  298. this.form.cooperation = this.cooperations.toString();
  299. this.checkedAgentlist = this.agentList.filter(item => this.cooperations.indexOf(item.brand) > -1)
  300. this.checkedBrandlist = this.checkedAgentlist.reduce((res, item, index, array) => {
  301. res.push(item.brand)
  302. return res;
  303. }, []);
  304. this.getQuerybrand()
  305. this.brandShow = false
  306. } else {
  307. console.log("至少选择一项")
  308. }
  309. },
  310. getTaskconfirm(e) {
  311. this.form.tasklist = e[0].label;
  312. },
  313. delAgent(index) {
  314. this.checkedAgentlist.splice(index, 1)
  315. },
  316. submit() {
  317. this.$refs.uForm.validate(valid => {
  318. if (valid) {
  319. this.brandAgentLvQueryList = this.checkedAgentlist.filter(item => (item.disabledGroup != true))
  320. let checkenLength = this.checkedAgentlist.filter(item => (item.checked == false&&item.disabledGroup==false))
  321. if (!this.brandAgentLvQueryList.length) return this.$u.toast('未正确选择经销商,请正确选择');
  322. if (checkenLength.length != 0) return this.$u.toast('请选择' + checkenLength[0].brand + "品牌签约任务");
  323. if (!this.protocol) return this.$u.toast('请阅读并同意用户协议和隐私协议');
  324. this.setData()
  325. } else {
  326. console.log('验证失败');
  327. }
  328. });
  329. },
  330. setData() {
  331. this.brandAgentLvQueryList = this.brandAgentLvQueryList.reduce((res, item) => {
  332. res.push({
  333. agent_id: item.agent_id,
  334. agent_name: item.name,
  335. brand: item.brand,
  336. brandCode: item.brandCode,
  337. kunnr: item.kunnr,
  338. lvCount: parseInt(item.taskNum.substring(2)).toString(),
  339. showLv: item.taskNum,
  340. spart: "10",
  341. vkorg: "8100",
  342. vtweg: "10"
  343. })
  344. return res;
  345. }, []);
  346. let data = {
  347. "brandAgentLvQueryList": this.brandAgentLvQueryList,
  348. "city": this.formData.city,
  349. "contactName": this.formData.name,
  350. "district": this.formData.district,
  351. "jd": this.formData.longitude,
  352. "licenseUrl": this.dataUrl.licenseUrl,
  353. "mobileCode": this.formData.code,
  354. "province": this.formData.province,
  355. "storeImageUrl": this.dataUrl.storeUrl,
  356. "storeName": this.formData.store,
  357. "storePhone": this.formData.phone,
  358. "version": 1.00,
  359. "wd": this.formData.latitude,
  360. "addressInfo": this.formData.addressInfo
  361. }
  362. this.loading = true
  363. request({
  364. url: '/sailun/appStoreBasicInfo/storeReg',
  365. method: 'post',
  366. data: data
  367. }).then(res => {
  368. if (res.data.code == 0) {
  369. this.$u.toast("注册资料已提交成功");
  370. setTimeout(() => {
  371. this.$u.route({
  372. url: 'pages/login/index',
  373. })
  374. uni.$emit('loginphone',this.formData.phone)
  375. }, 2000)
  376. }
  377. if (res.data.code == 500) {
  378. this.$u.toast(res.data.msg);
  379. }
  380. }).catch(err => {
  381. console.log(err)
  382. }).finally(() => {
  383. this.loading = false
  384. })
  385. }
  386. },
  387. onReady() {
  388. this.$refs.uForm.setRules(this.rules);
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. .content {
  394. padding: 24rpx;
  395. text-align: center;
  396. .u-checkbox[data-v-54acf820] {
  397. display: flex;
  398. justify-content: center;
  399. }
  400. }
  401. </style>