register_3.vue 12 KB

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