uploadContact.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="content-upload-contact">
  3. <view class="title"> 您暂未绑定手机号<br />请按选择方式补充信息后确认签到</view>
  4. <radio-group style="margin-left: 35rpx" @change="radioChange">
  5. <radio
  6. v-for="item in radioList"
  7. :key="item.value"
  8. :class="['class-radio', radioValue === item.value && 'active-radio']"
  9. :value="item.value"
  10. color="#CAAF8B"
  11. :checked="item.value == 1"
  12. >{{ item.label }}</radio
  13. >
  14. </radio-group>
  15. <view class="content-bind" v-if="radioValue == 1">
  16. <view class="ipt-item">
  17. <view class="item-label" @click="isAreaCode = true">
  18. {{ `+${countryCode}` }}
  19. <u-icon :name="isAreaCode ? 'arrow-up' : 'arrow-down'" color="#999999" size="28"></u-icon>
  20. </view>
  21. <input type="number" v-model="phoneNumber" placeholder="请输入手机号" />
  22. </view>
  23. <view class="ipt-item">
  24. <input type="number" v-model="phoneCode" placeholder="请输入4位手机号验证码" />
  25. <u-verification-code :seconds="seconds" ref="uCode" @change="codeTimeChange"></u-verification-code>
  26. <view class="item-code" @click="getCode">{{ tips }} </view>
  27. </view>
  28. <view class="ipt-item">
  29. <input type="text" v-model="userName" placeholder="请输入您的姓名" />
  30. </view>
  31. <view class="ipt-item">
  32. <input type="text" v-model="corporateName" placeholder="请输入您的公司名称" />
  33. </view>
  34. </view>
  35. <view class="upload-card" v-else>
  36. <image v-if="fileUrl" :src="fileUrl"></image>
  37. <view v-else class="upload-content" @click="uploadCardHandler">
  38. <text>+</text>
  39. <text>点击上传名片</text>
  40. </view>
  41. </view>
  42. <view class="button-bind" @click="submitButton">确认签到</view>
  43. <view class="select-box">
  44. <u-popup v-model="isAreaCode" mode="bottom" @close="cancel">
  45. <view class="box" style="color: #333333; font-size: 28rpxrpx">请选择您的国际区号</view>
  46. <view class="box" v-for="item in mobileAreaCode" :key="item.code" style="color: #2c83ff" @click="areacode(item.code)">{{ item.name }}</view>
  47. <view class="box box-bottom" style="color: #a9afb8" @click="cancel">取消</view>
  48. </u-popup>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { MobileAreaCode } from "@/utils/mobileCode";
  54. import { uploadurl, User, Mine } from "@/config/api.js";
  55. export default {
  56. data() {
  57. return {
  58. radioValue: 1,
  59. radioList: [
  60. {
  61. label: "填写手机号/机构名",
  62. value: 1,
  63. },
  64. {
  65. label: "上传名片",
  66. value: 2,
  67. },
  68. ],
  69. seconds: 60,
  70. tips: "获取验证码",
  71. countryCode: "86",
  72. isAreaCode: false,
  73. phoneNumber: "",
  74. phoneCode: "",
  75. userName: "",
  76. corporateName: "",
  77. fileUrl: "",
  78. };
  79. },
  80. computed: {
  81. mobileAreaCode() {
  82. return MobileAreaCode;
  83. },
  84. },
  85. props: {
  86. codeId: {},
  87. },
  88. methods: {
  89. radioChange(e) {
  90. console.log(e);
  91. this.radioValue = e.detail.value;
  92. },
  93. // 选择区号的取消
  94. cancel() {
  95. this.isAreaCode = false;
  96. },
  97. // 选择了地区的区号
  98. areacode(num) {
  99. this.countryCode = num;
  100. this.isAreaCode = false;
  101. },
  102. codeTimeChange(val) {
  103. this.tips = val;
  104. },
  105. /* 获取邮箱验证码 */
  106. async getCode() {
  107. if (this.$refs.uCode.canGetCode) {
  108. if (!this.phoneNumber) {
  109. this.$util.toast("请先输入手机号");
  110. return;
  111. }
  112. const res = await User.getPhoneCode({
  113. Mobile: this.phoneNumber,
  114. AreaNum: this.countryCode,
  115. });
  116. if (res.Ret === 200) {
  117. this.$refs.uCode.start();
  118. }
  119. }
  120. },
  121. // 上传名片
  122. uploadCardHandler() {
  123. this.$util.upload.Single(uploadurl, (res) => {
  124. let data = JSON.parse(res.data);
  125. if (data.Ret === 200) {
  126. this.fileUrl = data.Data.ResourceUrl;
  127. }
  128. });
  129. },
  130. // 确认签到
  131. async submitButton() {
  132. if (this.radioValue == 1) {
  133. if (this.phoneNumber && this.phoneCode && this.userName && this.corporateName) {
  134. this.submitPost();
  135. } else {
  136. let msg = !this.phoneNumber
  137. ? "请输入手机号"
  138. : !this.phoneCode
  139. ? "请输入验证码"
  140. : !this.userName
  141. ? "请输入姓名"
  142. : !this.corporateName
  143. ? "请输入公司名称"
  144. : "";
  145. this.$util.toast(msg);
  146. }
  147. } else {
  148. if (!this.fileUrl) {
  149. this.$util.toast("请上传名片");
  150. return;
  151. }
  152. this.submitPost();
  153. }
  154. },
  155. async submitPost() {
  156. const res = await Mine.activity_signin_byHand({
  157. ActivityId: this.codeId || 2161, //活动ID
  158. CountryCode: this.countryCode, //区号
  159. Mobile: this.phoneNumber, //手机号
  160. VCode: this.phoneCode, //验证码
  161. CompanyName: this.corporateName, //公司名称
  162. BusinessCard: this.fileUrl, //名片地址
  163. RealName: this.userName, //姓名
  164. SigninType: Number(this.radioValue), //签到方式,1:填写手机号/机构名称;2:上传名片
  165. });
  166. if (res.Ret === 200) {
  167. this.$emit("getDetail");
  168. }
  169. },
  170. },
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .content-upload-contact {
  175. .title {
  176. text-align: center;
  177. color: #fff;
  178. font-weight: 500;
  179. font-size: 42rpx;
  180. line-height: 60rpx;
  181. margin-bottom: 70rpx;
  182. }
  183. .class-radio {
  184. color: #fff;
  185. font-size: 32rpx;
  186. font-weight: normal;
  187. margin-right: 50rpx;
  188. }
  189. .active-radio {
  190. color: #caaf8b;
  191. }
  192. .content-bind {
  193. padding: 10rpx;
  194. margin-bottom: 50rpx;
  195. }
  196. .ipt-item {
  197. display: flex;
  198. align-items: center;
  199. font-size: 34rpx;
  200. height: 78rpx;
  201. margin-top: 30rpx;
  202. .item-label {
  203. display: flex;
  204. align-items: center;
  205. justify-content: space-between;
  206. width: 167rpx;
  207. margin-right: 10rpx;
  208. height: 100%;
  209. background-color: #fff;
  210. color: #999;
  211. padding: 0 25rpx;
  212. border-radius: 8rpx;
  213. }
  214. input {
  215. flex: 1;
  216. background-color: #f7f7f7;
  217. height: 100%;
  218. border-radius: 8rpx;
  219. padding-left: 30rpx;
  220. }
  221. .item-code {
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. width: 185rpx;
  226. height: 60rpx;
  227. border: 2rpx solid #caaf8b;
  228. border-radius: 4rpx;
  229. color: #caaf8b;
  230. font-size: 28rpx;
  231. margin-left: 10rpx;
  232. }
  233. }
  234. .button-bind {
  235. display: flex;
  236. align-items: center;
  237. justify-content: center;
  238. width: 349rpx;
  239. height: 78rpx;
  240. background: linear-gradient(180deg, #e5cfb1 0%, #caaf8b 100%);
  241. border-radius: 4rpx;
  242. margin: 0 auto;
  243. color: #333333;
  244. font-weight: 500;
  245. font-size: 32rpx;
  246. }
  247. .upload-card {
  248. width: 690rpx;
  249. height: 431rpx;
  250. background: #333333;
  251. border: 4rpx solid #caaf8b;
  252. border-radius: 4rpx;
  253. margin: 25rpx auto 50rpx;
  254. display: flex;
  255. align-items: center;
  256. box-sizing: border-box;
  257. image {
  258. width: 100%;
  259. height: 100%;
  260. }
  261. .upload-content {
  262. width: 100%;
  263. color: #caaf8b;
  264. text {
  265. font-size: 80rpx;
  266. font-weight: 700;
  267. width: 100%;
  268. text-align: center;
  269. }
  270. text:last-child {
  271. font-weight: 400;
  272. font-size: 32rpx;
  273. }
  274. }
  275. }
  276. }
  277. </style>