zhuce.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view>
  3. <cu-custom :isBack="true" >
  4. <block slot="backText">返回</block>
  5. <block slot="content">用户注册</block>
  6. </cu-custom>
  7. <form>
  8. <view class="cu-form-group">
  9. <view class="title">姓名</view>
  10. <input placeholder="请输入姓名" name="input" v-model="myFormData.username"></input>
  11. </view>
  12. <view class="cu-form-group">
  13. <view class="title">单位名称</view>
  14. <input placeholder="请输入公司名称" name="input" v-model="myFormData.companyname"></input>
  15. <!-- <text style="display: none;" >{{company}}</text> -->
  16. </view>
  17. <view class="cu-form-group">
  18. <view class="title">单位地址</view>
  19. <input placeholder="请输入公司地址" name="input" v-model="myFormData.dizhi"></input>
  20. </view>
  21. <view class="cu-form-group">
  22. <view class="title">邮箱</view>
  23. <input placeholder="请输入公司邮箱" name="input" v-model="myFormData.email"></input>
  24. </view>
  25. -->
  26. <!---->
  27. <view class="cu-form-group margin-top">
  28. <view class="title">性别</view> <input type="text" v-model="myFormData.sex" value="myFormData.sex"/> <text v-model="myFormData.sex" >{{myFormData.sex}}</text>
  29. <switch class='switch-sex' @change="SwitchC" :class="switchC?'checked':''" :checked="switchC?true:false"></switch>
  30. </view>
  31. <!--
  32. <view class="cu-form-group">
  33. <view class="title">邮箱</view>
  34. <input placeholder="输入邮箱" name="input" v-model="myFormData.email"></input>
  35. </view> -->
  36. <view class="cu-form-group">
  37. <view class="title">密码</view>
  38. <input placeholder="请输入六位以上密码" name="input" type="password" v-model="myFormData.password"></input>
  39. </view>
  40. <view class="cu-form-group">
  41. <view class="title">确认密码</view>
  42. <input placeholder="请确认密码" name="input" type="password" v-model="myFormData.confirm"></input>
  43. </view>
  44. <!--
  45. <view class="cu-form-group margin-top shadow-warp" :class="[shape=='round'?'round':'']">
  46. <view class="title"><text class="cuIcon-mobile margin-right-xs"></text>手机号:</view>
  47. <input placeholder="请输入手机号" type="number" maxlength="11" v-model="phone"></input>
  48. </view>
  49. -->
  50. <view class="cu-form-group margin-top">
  51. <view class="title">手机号码</view>
  52. <input placeholder="输入手机号码" type="number" maxlength="11" name="input" v-model="myFormData.phone"></input>
  53. <view class="cu-capsule radius">
  54. <view class='cu-tag bg-blue '>
  55. +86
  56. </view>
  57. </view>
  58. </view>
  59. <view class="cu-form-group margin-top">
  60. <view class="title">验证码</view>
  61. <input placeholder="短信验证码" type="number" name="input" v-model="myFormData.smsCode"></input>
  62. <view class="action">
  63. <button class="cu-btn line-blue sm" :disabled="!isSendSMSEnable" @click="onSMSSend"> {{ getSendBtnText }}</button>
  64. </view>
  65. </view>
  66. <view class="padding flex flex-direction">
  67. <button class="cu-btn bg-blue lg" @click="onSubmit">注册并登录</button>
  68. </view>
  69. </form>
  70. </view>
  71. </template>
  72. <script>
  73. import { mapActions } from "vuex"
  74. import configService from '@/common/service/config.service.js';
  75. import { ACCESS_TOKEN,USER_NAME,USER_INFO } from "@/common/util/constants"
  76. import {formatDate} from '@/common/util/date.js';
  77. export default {
  78. data() {
  79. return {
  80. index: -1,
  81. switchC: true,
  82. imgList: [],
  83. uploadUrl:"/sys/common/upload",
  84. companyname:"",
  85. myFormData:{
  86. dizhi:'',
  87. youxiang:'',
  88. smsCode:'',
  89. avatar:'',
  90. companyname:'',
  91. username:'',
  92. sex:"男",
  93. confirm:'',
  94. phone:'',
  95. email:'',
  96. id:'',
  97. code:'',
  98. },
  99. smsCountDown: 0,
  100. smsCountInterval: null,
  101. };
  102. },
  103. onLoad: function (option) {
  104. //console.log(this.myFormData.sex)
  105. //console.log(formatDate(new Date(),"yyyy-MM-dd"))
  106. //console.log("this.$Route.query",this.$Route.query);
  107. let query=this.$Route.query
  108. if(query){
  109. this.myFormData=query;
  110. if(this.myFormData.sex=='女'){
  111. this.switchC = false
  112. }else if(this.myFormData.sex=='男'){
  113. this.switchC = true
  114. }
  115. if(this.myFormData.avatar){
  116. this.imgList=[this.myFormData.avatar]
  117. }
  118. if(!this.myFormData.birthday){
  119. this.myFormData.birthday= '无'
  120. }
  121. if(this.myFormData.identity=='普通成员'){
  122. this.myFormData.identity = 1
  123. }else if(this.myFormData.identity=='上级'){
  124. this.myFormData.identity = 2
  125. }
  126. if(this.myFormData.status=='正常'){
  127. this.myFormData.status = 1
  128. }else if(this.myFormData.status=='冻结'){
  129. this.myFormData.status = 2
  130. }
  131. this.Avatar=this.myFormData.avatar
  132. Object.keys(this.myFormData).map(key=>{
  133. if(this.myFormData[key]=='无'){
  134. this.myFormData[key] = ''
  135. }
  136. })
  137. console.log("this.myFormData",this.myFormData)
  138. }
  139. },
  140. computed: {
  141. /* company(){
  142. //console.log(data)
  143. return company;
  144. }, */
  145. isSendSMSEnable() {
  146. return this.smsCountDown <= 0 && this.myFormData.phone>1111;
  147. },
  148. getSendBtnText() {
  149. if (this.smsCountDown > 0) {
  150. return this.smsCountDown + '秒后发送';
  151. } else {
  152. return '发送验证码';
  153. }
  154. },
  155. canSMSLogin() {
  156. return this.userName.length > 4 && this.smsCode.length > 4;
  157. },
  158. canPwdLogin() {
  159. return this.userName.length > 4 && this.password.length > 4;
  160. },
  161. },
  162. mounted() {
  163. },
  164. methods: {
  165. ...mapActions([ "mLogin","PhoneLogin","mSign", "ThirdLogin" ]),
  166. onSMSSend() {
  167. let smsParams = {};
  168. smsParams.phone=this.myFormData.phone;
  169. smsParams.smsmode="0";
  170. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  171. if(!smsParams.phone || smsParams.phone.length==0){
  172. this.$tip.toast('请输入手机号');
  173. return false
  174. }
  175. if(!checkPhone.test(smsParams.phone)){
  176. this.$tip.toast('请输入正确的手机号');
  177. return false
  178. }
  179. this.$http.post("/ibps/business/v3/mobile/sys/verification",smsParams).then(res=>{
  180. if(res.data.state==200){
  181. this.smsCountDown = 60;
  182. this.startSMSTimer();
  183. }else{
  184. console.log(res)
  185. this.smsCountDown = 0;
  186. this.$tip.toast("发送异常");
  187. }
  188. });
  189. },
  190. startSMSTimer() {
  191. this.smsCountInterval = setInterval(() => {
  192. this.smsCountDown--;
  193. if (this.smsCountDown <= 0) {
  194. clearInterval(this.smsCountInterval);
  195. }
  196. }, 1000);
  197. },
  198. onSubmit() {
  199. let myForm = this.myFormData;
  200. let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
  201. let checkEmail = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
  202. console.log("myForm",myForm)
  203. if(!myForm.username || myForm.username.length==0){
  204. this.$tip.alert('请输入姓名');
  205. return false
  206. }
  207. if(!myForm.companyname || myForm.companyname.length==0){
  208. this.$tip.alert('请输入公司名称');
  209. return false
  210. }
  211. if(!myForm.password || myForm.password.length<6){
  212. this.$tip.alert('正确输入密码');
  213. return false
  214. }
  215. if(myForm.password != myForm.confirm){
  216. this.$tip.alert('两次输入密码不一致');
  217. return false
  218. }
  219. if(!myForm.phone || myForm.phone.length==0){
  220. this.$tip.alert('请输入手机号');
  221. return false
  222. }
  223. if(!checkPhone.test(myForm.phone)){
  224. this.$tip.alert('请输入正确的手机号');
  225. return false
  226. }
  227. if(!myForm.smsCode || myForm.smsCode.length!=6){
  228. this.$tip.alert('请输入六位验证码');
  229. return false
  230. }
  231. //this.myFormData.id = this.$store.getters.userid
  232. console.log('myform',this.myFormData)
  233. //首先往客户意向表加数据
  234. let data =
  235. {
  236. id: "",
  237. keHuMingCheng: myForm.companyname, //客户名称
  238. keHuDianHua:myForm.phone, //电话
  239. youXiang:myForm.email , //邮箱
  240. lianXiRen: myForm.username, //联系人
  241. laiYuanQuDao: "手机注册", //来源
  242. diZhi: myForm.dizhi, //地址
  243. beiZhu: "", //备注
  244. xiaoShouRenYuan: "", //销售人
  245. qianZaiZhuanYiShi: formatDate(new Date(),"yyyy-MM-dd")
  246. }
  247. let parajjj={
  248. boCode:"yxkh",
  249. version:"0",
  250. formKey:"yxkh",
  251. pk:"",
  252. data:JSON.stringify(data)
  253. }
  254. //ibps/business/v3/data/template/saveFormData/vo
  255. this.$tip.loading();
  256. let that=this;
  257. this.$http.post("ibps/business/v3/data/template/saveFormData/vo", parajjj).then(res => {
  258. if (res.data.state == 200) {
  259. let result = res.data.variables;
  260. that.myFormData.companyId=result.id;
  261. that.mSign(that.myFormData).then(res=>{
  262. console.log(res)
  263. that.$tip.loaded();
  264. if (res.data.state==200){
  265. console.log(res.data.data)
  266. console.log(that.$store)
  267. that.$tip.success('登录成功!')
  268. that.$Router.replaceAll({name:'index'})
  269. }
  270. else{
  271. that.$tip.error(res.data.message)
  272. }
  273. }).catch(()=>{
  274. that.$tip.loaded();
  275. that.$tip.error('提交失败')
  276. });
  277. }else{
  278. that.$tip.loaded();
  279. that.$tip.error('提交失败')
  280. }
  281. }).catch(()=>{
  282. this.$tip.loaded();
  283. this.$tip.error('提交失败')
  284. });;
  285. },
  286. DateChange(e) {
  287. this.myFormData.birthday = e.detail.value
  288. },
  289. SwitchC(e) {
  290. this.switchC = e.detail.value
  291. if(this.switchC){this.myFormData.sex="男"}else{this.myFormData.sex="女"}
  292. },
  293. ChooseImage() {
  294. var that=this;
  295. uni.chooseImage({
  296. count: 4, //默认9
  297. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  298. sourceType: ['album'], //从相册选择
  299. success: (res) => {
  300. that.$http.upload(that.$config.apiUrl+that.uploadUrl, {
  301. filePath: res.tempFilePaths[0],
  302. name: 'file'
  303. })
  304. .then(res => {
  305. that.myFormData.avatar=res.data.message;
  306. })
  307. .catch(err => {
  308. that.$tip.error(err.data.message)
  309. });
  310. this.imgList = res.tempFilePaths
  311. }
  312. });
  313. },
  314. ViewImage(e) {
  315. uni.previewImage({
  316. urls: this.imgList,
  317. current: e.currentTarget.dataset.url
  318. });
  319. },
  320. DelImg(e) {
  321. uni.showModal({
  322. title: '召唤师',
  323. content: '确定要删除这段回忆吗?',
  324. cancelText: '再看看',
  325. confirmText: '再见',
  326. success: res => {
  327. if (res.confirm) {
  328. this.imgList.splice(e.currentTarget.dataset.index, 1)
  329. }
  330. }
  331. })
  332. }
  333. }
  334. }
  335. </script>
  336. <style>
  337. .cu-form-group .title {
  338. min-width: calc(4em + 15px);
  339. }
  340. </style>