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