123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- <view class="apply-trial-page">
- <view class="tips">请上传您的名片信息,以便工作人员更好地为您服务</view>
- <view class="flex upload-wrap">
- <view class="box upload-box" @click="handleUploadCard">
- <image
- class="add-icon"
- src="./static/upload.png"
- mode="widthFix"
- v-if="!cardImg"
- ></image>
- <image class="bg-img" :src="cardImg" mode="widthFix" v-if="cardImg"></image>
- <view class="tips" v-if="!cardImg">上传您的名片</view>
- </view>
- <view class="box exp">
- <image class="bg-img" :src="globalImgUrls.idCardExp" mode="widthFix"></image>
- <view class="tips">名片示例</view>
- </view>
- </view>
- <view class="form-wrap">
- <van-field
- clearable
- label="姓名"
- :value="form.name"
- placeholder="请输入姓名"
- :border="false"
- title-width="70px"
- @change="inputChange('name', $event)"
- />
- <van-field
- clearable
- label="公司名"
- :value="form.companyName"
- placeholder="请输入公司名"
- :border="false"
- title-width="70px"
- @change="inputChange('companyName', $event)"
- />
- <van-field
- clearable
- label="手机号"
- type="number"
- :value="userInfo.mobile"
- placeholder="请输入手机号"
- :border="false"
- title-width="70px"
- disabled
- v-if="!userInfo.email"
- />
- <van-field
- label="关注品种"
- readonly
- :value="form.permission"
- placeholder="请选择关注品种"
- :border="false"
- is-link
- title-width="70px"
- @click-input="handleGoSelectVariety"
- />
- </view>
- <view class="global-btn-yellow-change btn" @click="handleSubmit">提交</view>
- </view>
- </template>
- <script>
- import { uploadImg } from '@/utils/upload'
- import {apiApplyPermission} from '@/api/user'
- export default {
- name: "ApplyTrial",
- data() {
- return {
- cardImg: '',//上传的名片地址
- form: {
- name: "",
- companyName: '',
- tel: '',
- permission: '',
- },
- source:"",//来源 1-我的 2-活动 3-图库 4-研报 5-问答 6价格驱动
- from_page:''
- }
- },
- onLoad(options){
- this.source=options.source
- this.from_page=options.from_page
- this.addEventListenerPermission()
- },
- onUnload(){
- uni.$off('selectPermission')
- },
- methods: {
- // 监听权限选择
- addEventListenerPermission(){
- uni.$on('selectPermission',(e)=>{
- this.form.permission=e.permissionList.join(',')
- })
- },
- inputChange(key, event) {
- this.form[key] = event.detail
- },
- // 上传名片
- async handleUploadCard() {
- const res = await uploadImg({count:1})
- this.cardImg=res[0]
- },
- // 去选择品种
- handleGoSelectVariety() {
-
- uni.navigateTo({
- url: "/pages-applyPermission/selectVariety",
- events:{},
- success: (res)=> {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('hasPermissionData', { data: this.form.permission })
- }
- })
- },
- // 提交
- async handleSubmit(){
- let params={
- business_card_url:this.cardImg,
- company_name:this.form.companyName,
- permission:this.form.permission,
- real_name:this.form.name,
- source:Number(this.source),
- from_page:this.from_page
- }
- if(!params.company_name){
- uni.showToast({
- title:"请填写公司名",
- icon:"none"
- })
- return
- }
- if(!params.real_name){
- uni.showToast({
- title:"请填写姓名",
- icon:"none"
- })
- return
- }
- if(!params.permission){
- uni.showToast({
- title:"请选择品种",
- icon:"none"
- })
- return
- }
- const res=await apiApplyPermission(params)
- if(res.code===200){
- uni.showToast({
- title:"申请成功",
- icon:"none"
- })
- this.$store.dispatch('getUserInfo')//重新获取一次个人信息
- setTimeout(()=>{
- uni.redirectTo({
- url:"/pages-applyPermission/applyResult"
- })
- },1000)
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .tips {
- background-color: #fbf3e8;
- color: $global-text-color-grey;
- font-size: $global-font-size-sm;
- padding: 14rpx 34rpx;
- }
- .upload-wrap {
- padding: 30rpx 34rpx 40rpx 34rpx;
- justify-content: space-between;
- .box {
- background-color: $global-bg-color-grey;
- width: 326rpx;
- height: 260rpx;
- border-radius: 16rpx;
- overflow: hidden;
- position: relative;
- .tips {
- background-color: rgba(0, 0, 0, 0.2);
- color: $global-text-color-white;
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- text-align: center;
- }
- .bg-img{
- width: 100%;
- height: 100%;
- }
- }
- .upload-box {
- .add-icon {
- width: 30%;
- position: absolute;
- top: 53rpx;
- left: 50%;
- transform: translateX(-50%);
- }
- }
- }
- .van-cell {
- border-bottom: 1px solid $global-border-color;
- }
- .form-wrap {
- border-top: 10rpx solid #f6f6f6;
- }
- .btn {
- width: 380rpx;
- margin-top: 80rpx;
- margin-left: auto;
- margin-right: auto;
- }
- </style>
|