index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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" v-show="!addressShow">
  59. <textarea auto-height placeholder="请输入详细地址" v-model="addressDetail" maxlength="26" @blur="testLength" />
  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.getTradeRequest();
  149. },
  150. onShow() {
  151. },
  152. // onShareAppMessage() {
  153. // return {
  154. // title: '分销小助手',
  155. // path:'/pages/index/index?scene=' + getApp().globalData.user_id
  156. // }
  157. // },
  158. methods: {
  159. addresspick(obj) {
  160. console.log(obj)
  161. this.addressObj = obj;
  162. this.txt = obj.province.name + obj.city.name;
  163. },
  164. getProvinceRequest(){
  165. let that = this;
  166. uni.request({
  167. url:getApp().globalData.shareUrl, //需要设置为全局
  168. method: 'POST',
  169. header: {
  170. 'content-type': 'application/x-www-form-urlencoded'
  171. },
  172. data: {
  173. method: 'province',
  174. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  175. sign: md5('province' + getApp().globalData.globalTimestamp),
  176. },
  177. success: res => {
  178. that.provinceArray = res.data.msg
  179. }
  180. });
  181. },
  182. getTradeRequest(){
  183. let that = this;
  184. uni.request({
  185. url:getApp().globalData.shareUrl, //需要设置为全局
  186. method: 'POST',
  187. header: {
  188. 'content-type': 'application/x-www-form-urlencoded'
  189. },
  190. data: {
  191. method: 'hangye',
  192. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  193. sign: md5('hangye' + getApp().globalData.globalTimestamp),
  194. },
  195. success: res => {
  196. that.tradeArray = res.data.msg
  197. }
  198. });
  199. },
  200. radioCheck(e){
  201. console.log(e.target.value)
  202. this.userSex = e.target.value;
  203. //this.gender = e.target.value == '0' ? '男' : '女';
  204. },
  205. changeCity(data) {
  206. this.txt = data.data.join('')
  207. console.log(data.data.join(''))
  208. },
  209. bindPickerChange(e,type) {
  210. let that = this;
  211. switch (type){
  212. case 'trade':
  213. that.tradeValue = that.tradeArray[e.target.value].name
  214. break;
  215. case 'profession':
  216. that.professionValue = that.professionArray[e.target.value].name
  217. break;
  218. case 'ends':
  219. that.endsValue = that.endsArray[e.target.value].name
  220. break;
  221. }
  222. },
  223. testLength(){
  224. if(this.addressDetail.length > 25){
  225. uni.showToast({
  226. title: '详细地址应为0-25个字符',
  227. icon: 'none'
  228. });
  229. }
  230. },
  231. formSubmit(e) {
  232. this.goCustomCardPage()
  233. //将下列代码加入到对应的检查位置
  234. //定义表单规则
  235. var rule = [
  236. {
  237. name: "selfName",
  238. checkType: "notnull",
  239. errorMsg: "姓名不能为空"
  240. },
  241. {
  242. name: "selfName",
  243. checkType: "string",
  244. checkRule: "2,15",
  245. errorMsg: "姓名不能少于2个汉字"
  246. },
  247. {
  248. name: "selfName",
  249. checkType: "reg",
  250. checkRule: "[\u4e00-\u9fa5]",
  251. errorMsg: "姓名需为中文"
  252. },
  253. {
  254. name: "trade",
  255. checkType: "notnull",
  256. errorMsg: "行业不能为空"
  257. }
  258. ];
  259. //进行表单检查
  260. var formData = e.detail.value;
  261. console.log(formData)
  262. var checkRes = graceChecker.check(formData, rule);
  263. if (checkRes) {
  264. this.txt === '请选择' ?
  265. uni.showToast({
  266. title: '请选择地区',
  267. icon: "none"
  268. }):
  269. this.submitRequest(formData);
  270. } else {
  271. uni.showToast({
  272. title: graceChecker.error,
  273. icon: "none"
  274. });
  275. }
  276. },
  277. submitRequest(params){
  278. console.log(params)
  279. let that = this;
  280. uni.request({
  281. url:getApp().globalData.shareUrl, //需要设置为全局
  282. method: 'POST',
  283. header: {
  284. 'content-type': 'application/x-www-form-urlencoded'
  285. },
  286. data: {
  287. method: 'common_guest_login',
  288. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  289. sign: md5('common_guest_login' + getApp().globalData.globalTimestamp),
  290. phone:getApp().globalData.userPhone,
  291. wxopenid:getApp().globalData.openId,
  292. name:params.selfName,
  293. sex:that.userSex,//0-女 1-男
  294. province:that.addressObj.province.id,//省份id
  295. city:that.addressObj.city.id,//城市id
  296. detailaddress:that.addressDetail,
  297. hangye:Number(params.trade) + 1,
  298. },
  299. success: res => {
  300. console.log(res)
  301. if(res.data.code === 200){
  302. that.loginObj = res.data.msg;
  303. getApp().globalData.userCodeNumber = that.loginObj.code;
  304. getApp().globalData.managerPhone = that.loginObj.qyjl_phone;
  305. getApp().globalData.managerName = that.loginObj.qyjl_name;
  306. getApp().globalData.addTime = that.loginObj.addtime;
  307. this.goCustomCardPage()
  308. }
  309. else {
  310. uni.showToast({
  311. title: res.data.msg,
  312. icon: 'none'
  313. });
  314. }
  315. }
  316. });
  317. },
  318. goCustomCardPage(){
  319. uni.redirectTo({
  320. url: '/pages/index/successPage/index?types='+'custom', //游客成功页面
  321. success: res => {},
  322. fail: () => {},
  323. complete: () => {}
  324. })
  325. }
  326. }
  327. }
  328. </script>
  329. <style lang="scss" scoped>
  330. .content {
  331. &_list{
  332. display: flex;
  333. flex-direction: row;
  334. align-items: center;
  335. justify-content:space-around;
  336. &_lable{
  337. }
  338. &_content{
  339. flex: 1;
  340. width: auto;
  341. text-align: right;
  342. }
  343. }
  344. }
  345. .content-box {
  346. width: 100%;
  347. /* height: 100%; */
  348. display: flex;
  349. flex-direction: column;
  350. align-items: center;
  351. /* justify-content: center; */
  352. }
  353. .header-box {
  354. width: 85%;
  355. height:80rpx;
  356. border: .5px dotted #00A1B4;
  357. border-radius: 50rpx;
  358. display: flex;
  359. justify-content: center;
  360. align-items: center;
  361. font-size: 24rpx;
  362. color:#00A1B4 ;
  363. /* font-family: PingFangSC-Regular; */
  364. margin-top: 2%;
  365. }
  366. .header-box image {
  367. width: 36rpx;
  368. height: 36rpx;
  369. margin-right: 1%;
  370. }
  371. .self-title-box {
  372. width: 90%;
  373. display: flex;
  374. align-items: center;
  375. font-size: 32rpx;
  376. letter-spacing: 2rpx;
  377. color:#3C3C3C ;
  378. /* font-family: SimHei; */
  379. margin: 4% auto;
  380. font-weight: bold;
  381. height: 50rpx;
  382. line-height: 50rpx;
  383. }
  384. .self-title-box image {
  385. width: 6rpx;
  386. height: 32rpx;
  387. margin-right: 2%;
  388. }
  389. .info-box {
  390. width: 90%;
  391. margin: 3% auto;
  392. height: 180rpx;
  393. border-bottom: 1px solid #f7f7f7;
  394. }
  395. .info-title-box {
  396. width: 100%;
  397. display: flex;
  398. align-items: center;
  399. font-size: 28rpx;
  400. height: 50rpx;
  401. line-height: 50rpx;
  402. }
  403. .info-title-box image{
  404. width: 15rpx;
  405. height: 15rpx;
  406. margin-right: 2%;
  407. }
  408. .info-value-box input {
  409. height: 88rpx;
  410. background: #f7f7f7;
  411. font-size: 28rpx;
  412. padding-left: 4%;
  413. margin: 2% auto;
  414. }
  415. .select-box {
  416. height: 88rpx;
  417. background: #f7f7f7;
  418. font-size: 28rpx;
  419. padding-left: 4%;
  420. margin: 2% auto;
  421. color: #888;
  422. line-height: 88rpx;
  423. }
  424. .info-gender-box {
  425. margin: 3% auto;
  426. font-size: 28rpx;
  427. }
  428. .form-radio {
  429. transform: scale(0.6);
  430. }
  431. .padding-left-2 {
  432. padding-left: 2%;
  433. }
  434. .margin-right-10 {
  435. margin-right: 10%;
  436. }
  437. .border-line-box {
  438. width: 100%;
  439. height: 20rpx;
  440. background: #f7f7f7;
  441. }
  442. .picker-box{
  443. display: flex;
  444. align-items: center;
  445. justify-content: space-between;
  446. height: 60rpx;
  447. line-height: 60rpx;
  448. background: #f7f7f7;
  449. height: 88rpx;
  450. line-height: 88rpx;
  451. background: #f7f7f7;
  452. font-size: 28rpx;
  453. padding-left: 4%;
  454. }
  455. .uni-input image {
  456. width: 40rpx;
  457. height: 40rpx;
  458. margin-right: 2%;
  459. float: right;
  460. }
  461. .textarea-box {
  462. background: #f7f7f7;
  463. min-height: 120rpx;
  464. font-size: 28rpx;
  465. margin: 5% auto;
  466. padding: 4%;
  467. margin-bottom: 8%;
  468. }
  469. .submit-bth {
  470. width: 80%;
  471. height: 80rpx;
  472. line-height: 80rpx;
  473. background: #00A1B4!important;
  474. -webkit-box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
  475. box-shadow: 0 2rpx 16rpx 0 rgba(60,120,109,0.20);
  476. border-radius: 50rpx;
  477. margin-bottom: 10%;
  478. font-size: 30rpx;
  479. }
  480. </style>