applyPermission.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. source:"",//来源 1-我的 2-活动 3-图库 4-研报 5-问答 6价格驱动
  79. from_page:''
  80. }
  81. },
  82. onLoad(options){
  83. this.source=options.source
  84. this.from_page=options.from_page
  85. this.addEventListenerPermission()
  86. },
  87. onUnload(){
  88. uni.$off('selectPermission')
  89. },
  90. methods: {
  91. // 监听权限选择
  92. addEventListenerPermission(){
  93. uni.$on('selectPermission',(e)=>{
  94. this.form.permission=e.permissionList.join(',')
  95. })
  96. },
  97. inputChange(key, event) {
  98. this.form[key] = event.detail
  99. },
  100. // 上传名片
  101. async handleUploadCard() {
  102. const res = await uploadImg({count:1})
  103. this.cardImg=res[0]
  104. },
  105. // 去选择品种
  106. handleGoSelectVariety() {
  107. uni.navigateTo({
  108. url: "/pages-applyPermission/selectVariety",
  109. events:{},
  110. success: (res)=> {
  111. // 通过eventChannel向被打开页面传送数据
  112. res.eventChannel.emit('hasPermissionData', { data: this.form.permission })
  113. }
  114. })
  115. },
  116. // 提交
  117. async handleSubmit(){
  118. let params={
  119. business_card_url:this.cardImg,
  120. company_name:this.form.companyName,
  121. permission:this.form.permission,
  122. real_name:this.form.name,
  123. source:Number(this.source),
  124. from_page:this.from_page
  125. }
  126. if(!params.company_name){
  127. uni.showToast({
  128. title:"请填写公司名",
  129. icon:"none"
  130. })
  131. return
  132. }
  133. if(!params.real_name){
  134. uni.showToast({
  135. title:"请填写姓名",
  136. icon:"none"
  137. })
  138. return
  139. }
  140. if(!params.permission){
  141. uni.showToast({
  142. title:"请选择品种",
  143. icon:"none"
  144. })
  145. return
  146. }
  147. const res=await apiApplyPermission(params)
  148. if(res.code===200){
  149. uni.showToast({
  150. title:"申请成功",
  151. icon:"none"
  152. })
  153. this.$store.dispatch('getUserInfo')//重新获取一次个人信息
  154. setTimeout(()=>{
  155. uni.redirectTo({
  156. url:"/pages-applyPermission/applyResult"
  157. })
  158. },1000)
  159. }
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .tips {
  166. background-color: #fbf3e8;
  167. color: $global-text-color-grey;
  168. font-size: $global-font-size-sm;
  169. padding: 14rpx 34rpx;
  170. }
  171. .upload-wrap {
  172. padding: 30rpx 34rpx 40rpx 34rpx;
  173. justify-content: space-between;
  174. .box {
  175. background-color: $global-bg-color-grey;
  176. width: 326rpx;
  177. height: 260rpx;
  178. border-radius: 16rpx;
  179. overflow: hidden;
  180. position: relative;
  181. .tips {
  182. background-color: rgba(0, 0, 0, 0.2);
  183. color: $global-text-color-white;
  184. position: absolute;
  185. bottom: 0;
  186. left: 0;
  187. width: 100%;
  188. text-align: center;
  189. }
  190. .bg-img{
  191. width: 100%;
  192. height: 100%;
  193. }
  194. }
  195. .upload-box {
  196. .add-icon {
  197. width: 30%;
  198. position: absolute;
  199. top: 53rpx;
  200. left: 50%;
  201. transform: translateX(-50%);
  202. }
  203. }
  204. }
  205. .van-cell {
  206. border-bottom: 1px solid $global-border-color;
  207. }
  208. .form-wrap {
  209. border-top: 10rpx solid #f6f6f6;
  210. }
  211. .btn {
  212. width: 380rpx;
  213. margin-top: 80rpx;
  214. margin-left: auto;
  215. margin-right: auto;
  216. }
  217. </style>