teamUserDetail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header :title='title'></cus-header>
  4. <view class="form">
  5. <view class="form-item adfacjb">
  6. <view class="form-item-left">姓名</view>
  7. <view class="form-item-right">
  8. <u-input v-model="userInfo.realName" placeholder="请输入团队人员姓名" border="none" style="font-size: 28rpx;color: #B3BFC8;line-height: 28rpx;" inputAlign="right"></u-input>
  9. </view>
  10. </view>
  11. <view class="form-item adfacjb">
  12. <view class="form-item-left">手机号码</view>
  13. <view class="form-item-right adf">
  14. <cus-phone ref="phoneInput"
  15. :init-code="areaCode"
  16. @validate="handleValidate"
  17. @phone-change="handlePhoneChange">
  18. </cus-phone>
  19. <u-input v-model="userInfo.mobile" placeholder="请输入手机号码" border="none" style="font-size: 28rpx;color: #B3BFC8;line-height: 28rpx;" inputAlign="right"></u-input>
  20. </view>
  21. </view>
  22. <view class="form-item adfacjb">
  23. <view class="form-item-left">邮箱</view>
  24. <view class="form-item-right">
  25. <u-input v-model="userInfo.email" placeholder="请输入邮箱" border="none" style="font-size: 28rpx;color: #B3BFC8;line-height: 28rpx;" inputAlign="right"></u-input>
  26. </view>
  27. </view>
  28. </view>
  29. <!-- <view class="type adfacjb" @click="typeShow=true">
  30. <view class="type-left">团队人员身份类型</view>
  31. <view class="type-right adfac">
  32. <text>{{typeText}}</text>
  33. <image :src="imgBase+'my_arrow_right.png'"></image>
  34. </view>
  35. </view> -->
  36. <view class="zt_btn" @click="handleConfirm">确定</view>
  37. <u-picker :itemHeight="88" :immediateChange="true" :show="typeShow" :columns="typeData" title="成员身份类型"
  38. @cancel="typeShow=false" @confirm="typeConfirm" keyName="name" ></u-picker>
  39. </view>
  40. </template>
  41. <script>
  42. import CusPhone from '@/components/CusPhone/index.vue'
  43. export default {
  44. components:{CusPhone},
  45. data(){
  46. return {
  47. type:'',
  48. title:'团队成员',
  49. userInfo:{
  50. id:'',
  51. coachId:JSON.parse(uni.getStorageSync('userInfo')).id,
  52. realName:'',
  53. areaCode:'+86',
  54. mobile:'',
  55. email:'',
  56. },
  57. typeText:'请选择',
  58. typeShow:false,
  59. typeData:[[
  60. {id:1,name:'团队Leader'},
  61. {id:2,name:'团队成员Member'},
  62. {id:3,name:'利益相关者Stakeholder'},
  63. {id:4,name:'赞助人Sponsor'}
  64. ]],
  65. areaCode:'+86',
  66. phoneRuleMap: {
  67. '+86': { len: 11, reg: /^1[3-9]\d{9}$/, tip: '中国大陆' }, // 中国内地
  68. '+852': { len: 8, reg: /^\d{8}$/, tip: '中国香港' }, // 中国香港
  69. '+853': { len: 8, reg: /^\d{8}$/, tip: '中国澳门' }, // 中国澳门
  70. '+886': { len: 10, reg: /^09\d{8}$/, tip: '中国台湾' }, // 中国台湾(09开头)
  71. '+1': { len: 10, reg: /^[2-9]\d{2}[2-9]\d{6}$/, tip: '美国/加拿大' }, // 美加(首位非0/1)
  72. '+81': { len: 11, reg: /^0[1-9]\d{9}$/, tip: '日本' }, // 日本(0开头)
  73. '+82': { len: 11, reg: /^01[0-9]\d{8}$/, tip: '韩国' }, // 韩国(01开头)
  74. '+65': { len: 8, reg: /^[689]\d{7}$/, tip: '新加坡' }, // 新加坡(6/8/9开头)
  75. '+60': { len: 10, reg: /^01[0-9]\d{7}$/, tip: '马来西亚' }, // 马来西亚(01开头)
  76. '+91': { len: 10, reg: /^[6-9]\d{9}$/, tip: '印度' }, // 印度(6-9开头)
  77. '+61': { len: 9, reg: /^\d{9}$/, tip: '澳大利亚' }, // 澳大利亚
  78. '+44': { len: 11, reg: /^7\d{10}$/, tip: '英国' }, // 英国(7开头)
  79. '+33': { len: 10, reg: /^[67]\d{9}$/, tip: '法国' }, // 法国(6/7开头)
  80. '+49': { len: 11, reg: /^[1-9]\d{10}$/, tip: '德国' }, // 德国
  81. '+34': { len: 9, reg: /^[67]\d{8}$/, tip: '西班牙' }, // 西班牙(6/7开头)
  82. '+39': { len: 10, reg: /^3\d{9}$/, tip: '意大利' }, // 意大利(3开头)
  83. '+66': { len: 10, reg: /^0\d{9}$/, tip: '泰国' }, // 泰国(0开头)
  84. '+84': { len: 10, reg: /^0\d{9}$/, tip: '越南' }, // 越南(0开头)
  85. '+971': { len: 9, reg: /^[569]\d{8}$/, tip: '阿联酋' }, // 阿联酋(5/6/9开头)
  86. '+90': { len: 10, reg: /^5\d{9}$/, tip: '土耳其' }, // 土耳其(5开头)
  87. '+32': { len: 9, reg: /^[45]\d{8}$/, tip: '比利时' }, // 比利时(4/5开头)
  88. '+31': { len: 9, reg: /^[6]\d{8}$/, tip: '荷兰' }, // 荷兰(6开头)
  89. '+46': { len: 10, reg: /^[7]\d{9}$/, tip: '瑞典' }, // 瑞典(7开头)
  90. '+41': { len: 9, reg: /^[7]\d{8}$/, tip: '瑞士' }, // 瑞士(7开头)
  91. '+358': { len: 9, reg: /^[45]\d{8}$/, tip: '芬兰' }, // 芬兰(4/5开头)
  92. '+45': { len: 8, reg: /^\d{8}$/, tip: '丹麦' }, // 丹麦
  93. '+30': { len: 10, reg: /^[69]\d{9}$/, tip: '希腊' }, // 希腊(6/9开头)
  94. '+36': { len: 9, reg: /^[23789]\d{8}$/, tip: '匈牙利' }, // 匈牙利
  95. '+359': { len: 9, reg: /^[89]\d{8}$/, tip: '保加利亚' }, // 保加利亚(8/9开头)
  96. '+380': { len: 10, reg: /^[34569]\d{9}$/, tip: '乌克兰' }, // 乌克兰
  97. '+7': { len: 11, reg: /^[9]\d{10}$/, tip: '俄罗斯/哈萨克斯坦' }, // 俄/哈(9开头)
  98. '+27': { len: 10, reg: /^[6789]\d{9}$/, tip: '南非' }, // 南非(6-9开头)
  99. '+63': { len: 11, reg: /^09\d{9}$/, tip: '菲律宾' }, // 菲律宾(09开头)
  100. '+92': { len: 11, reg: /^[3456789]\d{10}$/, tip: '巴基斯坦' }, // 巴基斯坦
  101. '+94': { len: 10, reg: /^[7]\d{9}$/, tip: '斯里兰卡' }, // 斯里兰卡(7开头)
  102. '+880': { len: 11, reg: /^01\d{9}$/, tip: '孟加拉国' }, // 孟加拉国(01开头)
  103. '+62': { len: 12, reg: /^0\d{11}$/, tip: '印度尼西亚' }, // 印尼
  104. '+966': { len: 9, reg: /^5\d{8}$/, tip: '沙特阿拉伯' }, // 沙特(5开头)
  105. '+971': { len: 9, reg: /^[569]\d{8}$/, tip: '阿联酋' }, // 阿联酋
  106. '+974': { len: 8, reg: /^[345679]\d{7}$/, tip: '卡塔尔' }, // 卡塔尔
  107. '+965': { len: 8, reg: /^[569]\d{7}$/, tip: '科威特' }, // 科威特
  108. '+20': { len: 10, reg: /^[120]\d{9}$/, tip: '埃及' }, // 埃及
  109. '+234': { len: 11, reg: /^[789]\d{10}$/, tip: '尼日利亚' }, // 尼日利亚
  110. '+254': { len: 9, reg: /^[7]\d{8}$/, tip: '肯尼亚' }, // 肯尼亚(7开头)
  111. '+66': { len: 10, reg: /^0\d{9}$/, tip: '泰国' }, // 泰国
  112. '+855': { len: 9, reg: /^[01]\d{8}$/, tip: '柬埔寨' }, // 柬埔寨
  113. '+84': { len: 10, reg: /^0\d{9}$/, tip: '越南' }, // 越南
  114. '+95': { len: 9, reg: /^[9]\d{8}$/, tip: '缅甸' }, // 缅甸(9开头)
  115. }
  116. }
  117. },
  118. onLoad(options) {
  119. this.type = options.type;
  120. if(options.id){
  121. this.title = '编辑成员';
  122. this.getDetail(options.id)
  123. }
  124. },
  125. methods:{
  126. // 手机号校验回调
  127. handleValidate(res) {
  128. this.areaCode = res.fullPhone;
  129. this.userInfo.areaCode = res.fullPhone;
  130. },
  131. getDetail(id){
  132. this.$api.get(`/core/member/${id}`).then(({data:res})=>{
  133. if(res.code!==0) return this.$showToast(res.msg)
  134. this.userInfo = {...this.userInfo,...res.data}
  135. this.areaCode = this.userInfo.areaCode||'+86';
  136. if(this.userInfo.areaCode) this.userInfo.mobile = this.userInfo.mobile.replace(this.userInfo.areaCode,'');
  137. })
  138. },
  139. typeConfirm(e){
  140. this.typeShow = false;
  141. },
  142. handleConfirm(){
  143. if(!this.userInfo.realName) return this.$showToast('请输入姓名')
  144. const rule = this.phoneRuleMap[this.areaCode];
  145. const phone = this.userInfo.mobile;
  146. if (rule) {
  147. if (phone.length !== rule.len) {
  148. return this.$showToast(`请输入${rule.len}位${rule.tip}手机号`)
  149. } else if (!rule.reg.test(phone)) {
  150. return this.$showToast(`请输入正确的${rule.tip}手机号`)
  151. }
  152. } else return this.$showToast(`请输入正确的手机号`)
  153. // if(!this.$reg.email(this.userInfo.email)) return this.$showToast('请输入正确的邮箱')
  154. const userInfo = JSON.parse(JSON.stringify(this.userInfo));
  155. if(this.areaCode!=='+86') userInfo.mobile = this.areaCode+userInfo.mobile;
  156. this.$api[this.userInfo.id?'put':'post']('/core/member',userInfo).then(({data:res})=>{
  157. if(res.code!==0) return this.$showToast(res.msg)
  158. this.$showToast(`${this.userInfo.id?'编辑':'添加'}成功`);
  159. uni.navigateBack();
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style scoped lang="scss">
  166. .default_page{
  167. padding: 0 24rpx 54rpx;
  168. box-sizing: border-box;
  169. background: #F7F7F7;
  170. .form{
  171. background: #FFFFFF;
  172. border-radius: 24rpx 24rpx 0rpx 0rpx;
  173. margin-top: 20rpx;
  174. &-item{
  175. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
  176. padding: 28rpx 24rpx;
  177. &-left{
  178. font-family: PingFangSC, PingFang SC;
  179. font-weight: 400;
  180. font-size: 30rpx;
  181. color: #002846;
  182. line-height: 42rpx;
  183. }
  184. &-right{
  185. flex: 1;
  186. padding-left: 40rpx;
  187. }
  188. }
  189. }
  190. .type{
  191. background: #FFFFFF;
  192. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  193. border-radius: 24rpx;
  194. margin-top: 20rpx;
  195. padding: 28rpx 24rpx;
  196. &-left{
  197. font-family: PingFangSC, PingFang SC;
  198. font-weight: 400;
  199. font-size: 30rpx;
  200. color: #002846;
  201. line-height: 42rpx;
  202. }
  203. &-right{
  204. text{
  205. font-family: PingFangSC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 28rpx;
  208. color: #B3BFC8;
  209. line-height: 40rpx;
  210. }
  211. image{
  212. width: 30rpx;
  213. height: 30rpx;
  214. box-sizing: border-box;
  215. }
  216. }
  217. }
  218. .zt_btn{
  219. width: calc(100% - 100rpx);
  220. position: fixed;
  221. left: 50rpx;
  222. bottom: 54px;
  223. }
  224. }
  225. </style>