index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <view class="content-box">
  3. <view class="header-box">
  4. <image src="/static/tips.png" mode="aspectFill"></image>
  5. <text>温馨提示:请填写以下信息,填写后信息不可修改</text>
  6. </view>
  7. <form @submit="formSubmit" style="width: 100%">
  8. <view class="self-title-box">
  9. <image src="/static/rect-icon.png" mode="aspectFill"></image>
  10. <text>登记信息</text>
  11. </view>
  12. <view class="info-box">
  13. <view class="info-title-box">
  14. <image src="/static/require-icon.png" mode="aspectFill"></image>
  15. <text>姓名</text>
  16. </view>
  17. <view class="info-value-box">
  18. <input type="text" placeholder="请输入姓名" name="selfName">
  19. </view>
  20. </view>
  21. <view class="info-box" style="height: 150rpx;">
  22. <view class="info-title-box">
  23. <image src="/static/require-icon.png" mode="aspectFill"></image>
  24. <text>性别</text>
  25. </view>
  26. <view class="info-gender-box">
  27. <radio-group @change="radioCheck" class="padding-left-2">
  28. <label class="radio margin-right-10"><radio value="1" :checked="userSex==='1'" color="#00A1B4" class="form-radio"/>男</label>
  29. <label class="radio"><radio value="0" :checked="userSex==='0'" color="#00A1B4" class="form-radio"/>女</label>
  30. </radio-group>
  31. </view>
  32. </view>
  33. <view class="info-box" style="height: 390rpx;">
  34. <view class="info-title-box">
  35. <image src="/static/require-icon.png" mode="aspectFill"></image>
  36. <text>所在城市</text>
  37. </view>
  38. <view class="info-value-box" style="margin: 2% auto;">
  39. <view class="uni-input picker-box">
  40. <view class="content" style="width: 100%;">
  41. <view class="content_list" style="width: 100%;">
  42. <view class="content_list_label" @click="addressShow = true" style="width: 100%;color: #888;">{{txt}}</view>
  43. <view class="content_list_content">
  44. <pickerAddress v-model="addressShow" @confirm="addresspick" />
  45. <image src="/static/right-arrow.png" mode="aspectFill"></image>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- <pickerAddress @change="changeCity" style="width: 100%;color: #888;">
  50. {{txt}}
  51. <image src="/static/right-arrow.png" mode="aspectFill"></image>
  52. </pickerAddress> -->
  53. <!-- <picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :range="provinceArray" :range-key="'name'" :value="multiIndex" style="width: 100%;color: #888;">
  54. {{txt}}
  55. <image src="/static/right-arrow.png" mode="aspectFill"></image>
  56. </picker> -->
  57. </view>
  58. <view class="textarea-box">
  59. <textarea auto-height fixed="true" placeholder="请输入详细地址" v-model="addressDetail" maxlength="26" name="detailAddress" />
  60. </view>
  61. </view>
  62. </view>
  63. <view class="info-box">
  64. <view class="info-title-box">
  65. <image src="/static/require-icon.png" mode="aspectFill"></image>
  66. <text>行业</text>
  67. </view>
  68. <view class="info-value-box">
  69. <picker @change="bindPickerChange($event,'trade')" :range="tradeArray" :range-key="'name'" class="select-box" name="trade">
  70. <view class="uni-input">{{tradeValue}}</view>
  71. </picker>
  72. </view>
  73. </view>
  74. <view class="info-box">
  75. <view class="info-title-box">
  76. <image src="/static/require-icon.png" mode="aspectFill"></image>
  77. <text>职业</text>
  78. </view>
  79. <view class="info-value-box">
  80. <picker @change="bindPickerChange($event,'profession')" :range="professionArray" :range-key="'name'" class="select-box" name="profession">
  81. <view class="uni-input">{{professionValue}}</view>
  82. </picker>
  83. </view>
  84. </view>
  85. <view class="info-box">
  86. <view class="info-title-box">
  87. <image src="/static/require-icon.png" mode="aspectFill"></image>
  88. <text>参观目的</text>
  89. </view>
  90. <view class="info-value-box">
  91. <picker @change="bindPickerChange($event,'ends')" :range="endsArray" :range-key="'name'" class="select-box" name="ends">
  92. <view class="uni-input">{{endsValue}}</view>
  93. </picker>
  94. </view>
  95. </view>
  96. <view class="info-box" style="border-bottom: none;">
  97. <view class="info-title-box">
  98. <text>您目前从事的家具品牌</text>
  99. </view>
  100. <view class="info-value-box">
  101. <input type="text" placeholder="请输入您目前从事的家具品牌" v-model="userBrand">
  102. </view>
  103. </view>
  104. <view style="width: 100%;">
  105. <button type="primary" class="submit-bth" formType="submit">提交</button>
  106. </view>
  107. </form>
  108. </view>
  109. </template>
  110. <script>
  111. var md5 = require("../../../common/md5.js");
  112. import pickerAddress from '@/components/liudx-pickerAddress/index.vue'
  113. var graceChecker = require("../../../common/graceChecker.js");
  114. export default {
  115. components: {
  116. pickerAddress,
  117. },
  118. data() {
  119. return {
  120. title: 'Hello',
  121. detailObj:{},
  122. shareContent:'',
  123. shareCode:'',
  124. storeImg:'',
  125. isAuthPhone:getApp().globalData.user_phone,
  126. userSex:'1',
  127. txt: '请选择',
  128. tradeValue:'请选择',
  129. tradeArray: [],
  130. professionValue:'请选择',
  131. professionArray:[],
  132. endsValue:'请选择',
  133. endsArray:[],
  134. provinceArray: [],
  135. addressShow: false,
  136. form: {
  137. province: '',
  138. city: '',
  139. },
  140. address: '',
  141. addressObj:{},
  142. userBrand:'',
  143. addressDetail:'',
  144. loginObj:{}
  145. }
  146. },
  147. onLoad() {
  148. //this.getProvinceRequest();
  149. this.getTradeRequest();
  150. this.getProfessionRequest();
  151. this.getEndsRequest();
  152. },
  153. onShow() {
  154. },
  155. // onShareAppMessage() {
  156. // return {
  157. // title: '分销小助手',
  158. // path:'/pages/index/index?scene=' + getApp().globalData.user_id
  159. // }
  160. // },
  161. methods: {
  162. addresspick(obj) {
  163. console.log(obj)
  164. this.addressObj = obj;
  165. this.txt = obj.province.name + obj.city.name;
  166. },
  167. getProvinceRequest(){
  168. let that = this;
  169. uni.request({
  170. url:getApp().globalData.shareUrl, //需要设置为全局
  171. method: 'POST',
  172. header: {
  173. 'content-type': 'application/x-www-form-urlencoded'
  174. },
  175. data: {
  176. method: 'province',
  177. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  178. sign: md5('province' + getApp().globalData.globalTimestamp),
  179. },
  180. success: res => {
  181. that.provinceArray = res.data.msg
  182. }
  183. });
  184. },
  185. getTradeRequest(){
  186. let that = this;
  187. uni.request({
  188. url:getApp().globalData.shareUrl, //需要设置为全局
  189. method: 'POST',
  190. header: {
  191. 'content-type': 'application/x-www-form-urlencoded'
  192. },
  193. data: {
  194. method: 'hangye',
  195. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  196. sign: md5('hangye' + getApp().globalData.globalTimestamp),
  197. },
  198. success: res => {
  199. that.tradeArray = res.data.msg
  200. }
  201. });
  202. },
  203. getProfessionRequest(){
  204. let that = this;
  205. uni.request({
  206. url:getApp().globalData.shareUrl, //需要设置为全局
  207. method: 'POST',
  208. header: {
  209. 'content-type': 'application/x-www-form-urlencoded'
  210. },
  211. data: {
  212. method: 'zhiye',
  213. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  214. sign: md5('zhiye' + getApp().globalData.globalTimestamp),
  215. },
  216. success: res => {
  217. that.professionArray = res.data.msg
  218. }
  219. });
  220. },
  221. getEndsRequest(){
  222. let that = this;
  223. uni.request({
  224. url:getApp().globalData.shareUrl, //需要设置为全局
  225. method: 'POST',
  226. header: {
  227. 'content-type': 'application/x-www-form-urlencoded'
  228. },
  229. data: {
  230. method: 'purpose',
  231. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  232. sign: md5('purpose' + getApp().globalData.globalTimestamp),
  233. },
  234. success: res => {
  235. that.endsArray = res.data.msg
  236. }
  237. });
  238. },
  239. radioCheck(e){
  240. console.log(e.target.value)
  241. this.userSex = e.target.value;
  242. //this.gender = e.target.value == '0' ? '男' : '女';
  243. },
  244. changeCity(data) {
  245. this.txt = data.data.join('')
  246. console.log(data.data.join(''))
  247. },
  248. bindPickerChange(e,type) {
  249. let that = this;
  250. switch (type){
  251. case 'trade':
  252. that.tradeValue = that.tradeArray[e.target.value].name
  253. break;
  254. case 'profession':
  255. that.professionValue = that.professionArray[e.target.value].name
  256. break;
  257. case 'ends':
  258. that.endsValue = that.endsArray[e.target.value].name
  259. break;
  260. }
  261. },
  262. formSubmit(e) {
  263. //将下列代码加入到对应的检查位置
  264. //定义表单规则
  265. var rule = [
  266. {
  267. name: "selfName",
  268. checkType: "notnull",
  269. errorMsg: "姓名不能为空"
  270. },
  271. {
  272. name: "detailAddress",
  273. checkType: "string",
  274. checkRule: "0,25",
  275. errorMsg: "详细地址应为0-25个字符"
  276. },
  277. {
  278. name: "trade",
  279. checkType: "notnull",
  280. errorMsg: "行业不能为空"
  281. },
  282. {
  283. name: "profession",
  284. checkType: "notnull",
  285. errorMsg: "职业不能为空"
  286. },
  287. {
  288. name: "ends",
  289. checkType: "notnull",
  290. errorMsg: "参观目的不能为空"
  291. },
  292. ];
  293. //进行表单检查
  294. var formData = e.detail.value;
  295. console.log(formData)
  296. var checkRes = graceChecker.check(formData, rule);
  297. if (checkRes) {
  298. this.txt === '请选择' ?
  299. uni.showToast({
  300. title: '请选择地区',
  301. icon: "none"
  302. }):
  303. this.submitRequest(formData);
  304. } else {
  305. uni.showToast({
  306. title: graceChecker.error,
  307. icon: "none"
  308. });
  309. }
  310. },
  311. submitRequest(params){
  312. console.log(params)
  313. let that = this;
  314. uni.request({
  315. url:getApp().globalData.shareUrl, //需要设置为全局
  316. method: 'POST',
  317. header: {
  318. 'content-type': 'application/x-www-form-urlencoded'
  319. },
  320. data: {
  321. method: 'common_guest_login',
  322. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  323. sign: md5('common_guest_login' + getApp().globalData.globalTimestamp),
  324. phone:getApp().globalData.userPhone,
  325. wxopenid:getApp().globalData.openId,
  326. name:params.selfName,
  327. sex:that.userSex,//0-女 1-男
  328. province:that.addressObj.province.id,//省份id
  329. city:that.addressObj.city.id,//城市id
  330. detailaddress:that.addressDetail,
  331. hangye:Number(params.trade) + 1,
  332. zhiye:Number(params.profession) + 1,
  333. purpose:Number(params.ends) + 1,
  334. brand:that.userBrand,
  335. },
  336. success: res => {
  337. console.log(res)
  338. if(res.data.code === 200){
  339. that.loginObj = res.data.msg;
  340. getApp().globalData.userCodeNumber = that.loginObj.code;
  341. getApp().globalData.managerPhone = that.loginObj.qyjl_phone;
  342. getApp().globalData.managerName = that.loginObj.qyjl_name;
  343. getApp().globalData.addTime = that.loginObj.addtime;
  344. this.goCustomCardPage(that.loginObj.pass)
  345. }
  346. else {
  347. uni.showToast({
  348. title: res.data.msg,
  349. icon: 'none'
  350. });
  351. }
  352. }
  353. });
  354. },
  355. goCustomCardPage(type){
  356. type === 1 ?
  357. uni.redirectTo({
  358. url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
  359. success: res => {},
  360. fail: () => {},
  361. complete: () => {}
  362. }):
  363. uni.redirectTo({
  364. url: '/pages/index/failPage/index', //失败页面
  365. success: res => {},
  366. fail: () => {},
  367. complete: () => {}
  368. });
  369. }
  370. }
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .content {
  375. &_list{
  376. display: flex;
  377. flex-direction: row;
  378. align-items: center;
  379. justify-content:space-around;
  380. &_lable{
  381. }
  382. &_content{
  383. flex: 1;
  384. width: auto;
  385. text-align: right;
  386. }
  387. }
  388. }
  389. .content-box {
  390. width: 100%;
  391. /* height: 100%; */
  392. display: flex;
  393. flex-direction: column;
  394. align-items: center;
  395. /* justify-content: center; */
  396. }
  397. .header-box {
  398. width: 85%;
  399. height:80rpx;
  400. border: .5px dotted #00A1B4;
  401. border-radius: 50rpx;
  402. display: flex;
  403. justify-content: center;
  404. align-items: center;
  405. font-size: 24rpx;
  406. color:#00A1B4 ;
  407. /* font-family: PingFangSC-Regular; */
  408. margin-top: 2%;
  409. }
  410. .header-box image {
  411. width: 36rpx;
  412. height: 36rpx;
  413. margin-right: 1%;
  414. }
  415. .self-title-box {
  416. width: 90%;
  417. display: flex;
  418. align-items: center;
  419. font-size: 32rpx;
  420. letter-spacing: 2rpx;
  421. color:#3C3C3C ;
  422. /* font-family: SimHei; */
  423. margin: 4% auto;
  424. font-weight: bold;
  425. height: 50rpx;
  426. line-height: 50rpx;
  427. }
  428. .self-title-box image {
  429. width: 6rpx;
  430. height: 32rpx;
  431. margin-right: 2%;
  432. }
  433. .info-box {
  434. width: 90%;
  435. margin: 3% auto;
  436. height: 180rpx;
  437. border-bottom: 1px solid #f7f7f7;
  438. }
  439. .info-title-box {
  440. width: 100%;
  441. display: flex;
  442. align-items: center;
  443. font-size: 28rpx;
  444. height: 50rpx;
  445. line-height: 50rpx;
  446. }
  447. .info-title-box image{
  448. width: 15rpx;
  449. height: 15rpx;
  450. margin-right: 2%;
  451. }
  452. .info-value-box input {
  453. height: 88rpx;
  454. background: #f7f7f7;
  455. font-size: 28rpx;
  456. padding-left: 4%;
  457. margin: 2% auto;
  458. }
  459. .select-box {
  460. height: 88rpx;
  461. background: #f7f7f7;
  462. font-size: 28rpx;
  463. padding-left: 4%;
  464. margin: 2% auto;
  465. color: #888;
  466. line-height: 88rpx;
  467. }
  468. .info-gender-box {
  469. margin: 3% auto;
  470. font-size: 28rpx;
  471. }
  472. .form-radio {
  473. transform: scale(0.6);
  474. }
  475. .padding-left-2 {
  476. padding-left: 2%;
  477. }
  478. .margin-right-10 {
  479. margin-right: 10%;
  480. }
  481. .border-line-box {
  482. width: 100%;
  483. height: 20rpx;
  484. background: #f7f7f7;
  485. }
  486. .picker-box{
  487. display: flex;
  488. align-items: center;
  489. justify-content: space-between;
  490. height: 60rpx;
  491. line-height: 60rpx;
  492. background: #f7f7f7;
  493. height: 88rpx;
  494. line-height: 88rpx;
  495. background: #f7f7f7;
  496. font-size: 28rpx;
  497. padding-left: 4%;
  498. }
  499. .uni-input image {
  500. width: 40rpx;
  501. height: 40rpx;
  502. margin-right: 2%;
  503. float: right;
  504. }
  505. .textarea-box {
  506. background: #f7f7f7;
  507. min-height: 120rpx;
  508. font-size: 28rpx;
  509. margin: 5% auto;
  510. padding: 4%;
  511. margin-bottom: 8%;
  512. }
  513. .submit-bth {
  514. width: 80%;
  515. height: 80rpx;
  516. line-height: 80rpx;
  517. background: #00A1B4!important;
  518. -webkit-box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
  519. box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
  520. border-radius: 50rpx;
  521. margin-bottom: 10%;
  522. font-size: 30rpx;
  523. }
  524. </style>