applyPermission.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="apply-trial-page">
  3. <view class="tips">请上传您的名片信息,以便工作人员更好地为您服务</view>
  4. <view class="flex upload-wrap">
  5. <view class="box upload-box" @click="handleUploadCard">
  6. <image
  7. class="add-icon"
  8. src="./static/upload.png"
  9. mode="widthFix"
  10. v-if="!cardImg"
  11. ></image>
  12. <image class="bg-img" :src="cardImg" mode="widthFix" v-if="cardImg"></image>
  13. <view class="tips" v-if="!cardImg">上传您的名片</view>
  14. </view>
  15. <view class="box exp">
  16. <image class="bg-img" :src="globalImgUrls.idCardExp" mode="widthFix"></image>
  17. <view class="tips">名片示例</view>
  18. </view>
  19. </view>
  20. <view class="form-wrap">
  21. <van-field
  22. clearable
  23. label="姓名"
  24. :value="form.name"
  25. placeholder="请输入姓名"
  26. :border="false"
  27. title-width="70px"
  28. @change="inputChange('name', $event)"
  29. />
  30. <van-field
  31. clearable
  32. label="公司名"
  33. :value="form.companyName"
  34. placeholder="请输入公司名"
  35. :border="false"
  36. title-width="70px"
  37. @change="inputChange('companyName', $event)"
  38. />
  39. <van-field
  40. clearable
  41. label="手机号"
  42. type="number"
  43. :value="userInfo.mobile"
  44. placeholder="请输入手机号"
  45. :border="false"
  46. title-width="70px"
  47. disabled
  48. v-if="!userInfo.email"
  49. />
  50. <van-field
  51. label="关注品种"
  52. readonly
  53. :value="form.permission"
  54. placeholder="请选择关注品种"
  55. :border="false"
  56. is-link
  57. title-width="70px"
  58. @click-input="handleGoSelectVariety"
  59. />
  60. </view>
  61. <view class="global-btn-yellow-change btn" @click="handleSubmit">提交</view>
  62. </view>
  63. </template>
  64. <script>
  65. import { uploadImg } from '@/utils/upload'
  66. import {apiApplyPermission} from '@/api/user'
  67. export default {
  68. name: "ApplyTrial",
  69. data() {
  70. return {
  71. cardImg: '',//上传的名片地址
  72. form: {
  73. name: "",
  74. companyName: '',
  75. tel: '',
  76. permission: ''
  77. },
  78. }
  79. },
  80. onLoad(){
  81. this.addEventListenerPermission()
  82. },
  83. onUnload(){
  84. uni.$off('selectPermission')
  85. },
  86. methods: {
  87. // 监听权限选择
  88. addEventListenerPermission(){
  89. uni.$on('selectPermission',(e)=>{
  90. this.form.permission=e.permissionList.join(',')
  91. })
  92. },
  93. inputChange(key, event) {
  94. this.form[key] = event.detail
  95. },
  96. // 上传名片
  97. async handleUploadCard() {
  98. const res = await uploadImg()
  99. this.cardImg=res[0]
  100. },
  101. // 去选择品种
  102. handleGoSelectVariety() {
  103. uni.navigateTo({
  104. url: "/pages-applyPermission/selectVariety",
  105. events:{},
  106. success: (res)=> {
  107. // 通过eventChannel向被打开页面传送数据
  108. res.eventChannel.emit('hasPermissionData', { data: this.form.permission })
  109. }
  110. })
  111. },
  112. // 提交
  113. async handleSubmit(){
  114. let params={
  115. business_card_url:this.cardImg,
  116. company_name:this.form.companyName,
  117. permission:this.form.permission,
  118. real_name:this.form.name,
  119. }
  120. if(!params.company_name){
  121. uni.showToast({
  122. title:"请填写公司名",
  123. icon:"none"
  124. })
  125. return
  126. }
  127. if(!params.real_name){
  128. uni.showToast({
  129. title:"请填写姓名",
  130. icon:"none"
  131. })
  132. return
  133. }
  134. if(!params.permission){
  135. uni.showToast({
  136. title:"请选择品种",
  137. icon:"none"
  138. })
  139. return
  140. }
  141. const res=await apiApplyPermission(params)
  142. if(res.code===200){
  143. uni.showToast({
  144. title:"申请成功",
  145. icon:"none"
  146. })
  147. this.$store.dispatch('getUserInfo')//重新获取一次个人信息
  148. setTimeout(()=>{
  149. uni.redirectTo({
  150. url:"/pages-applyPermission/applyResult"
  151. })
  152. },1000)
  153. }
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. .tips {
  160. background-color: #fbf3e8;
  161. color: $global-text-color-grey;
  162. font-size: $global-font-size-sm;
  163. padding: 14rpx 34rpx;
  164. }
  165. .upload-wrap {
  166. padding: 30rpx 34rpx 40rpx 34rpx;
  167. justify-content: space-between;
  168. .box {
  169. background-color: $global-bg-color-grey;
  170. width: 326rpx;
  171. height: 260rpx;
  172. border-radius: 16rpx;
  173. overflow: hidden;
  174. position: relative;
  175. .tips {
  176. background-color: rgba(0, 0, 0, 0.2);
  177. color: $global-text-color-white;
  178. position: absolute;
  179. bottom: 0;
  180. left: 0;
  181. width: 100%;
  182. text-align: center;
  183. }
  184. .bg-img{
  185. width: 100%;
  186. height: 100%;
  187. }
  188. }
  189. .upload-box {
  190. .add-icon {
  191. width: 30%;
  192. position: absolute;
  193. top: 53rpx;
  194. left: 50%;
  195. transform: translateX(-50%);
  196. }
  197. }
  198. }
  199. .van-cell {
  200. border-bottom: 1px solid $global-border-color;
  201. }
  202. .form-wrap {
  203. border-top: 10rpx solid #f6f6f6;
  204. }
  205. .btn {
  206. width: 380rpx;
  207. margin-top: 80rpx;
  208. margin-left: auto;
  209. margin-right: auto;
  210. }
  211. </style>