uploadContact.vue 7.9 KB

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