uploadContact.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. console.log(this.phoneNumber);
  96. },
  97. deep: true,
  98. immediate: true,
  99. },
  100. },
  101. methods: {
  102. radioChange(e) {
  103. console.log(e);
  104. this.radioValue = e.detail.value;
  105. },
  106. // 选择区号的取消
  107. cancel() {
  108. this.isAreaCode = false;
  109. },
  110. // 选择了地区的区号
  111. areacode(num) {
  112. this.countryCode = num;
  113. this.isAreaCode = false;
  114. },
  115. codeTimeChange(val) {
  116. this.tips = val;
  117. },
  118. /* 获取邮箱验证码 */
  119. async getCode() {
  120. if (this.$refs.uCode.canGetCode) {
  121. if (!this.phoneNumber) {
  122. this.$util.toast("请先输入手机号");
  123. return;
  124. }
  125. const res = await User.getPhoneCode({
  126. Mobile: this.phoneNumber,
  127. AreaNum: this.countryCode,
  128. });
  129. if (res.Ret === 200) {
  130. this.$refs.uCode.start();
  131. }
  132. }
  133. },
  134. // 上传名片
  135. uploadCardHandler() {
  136. this.$util.upload.Single(uploadurl, (res) => {
  137. let data = JSON.parse(res.data);
  138. if (data.Ret === 200) {
  139. this.fileUrl = data.Data.ResourceUrl;
  140. }
  141. });
  142. },
  143. // 确认签到
  144. async submitButton() {
  145. if (this.radioValue == 1) {
  146. if (this.phoneNumber && (this.itemDetail.Mobile || this.phoneCode) && this.userName && this.corporateName) {
  147. this.submitPost();
  148. } else {
  149. let msg = !this.phoneNumber ? "请输入手机号" : !this.itemDetail.Mobile && this.phoneCode ? "请输入验证码" : !this.userName ? "请输入姓名" : !this.corporateName ? "请输入公司名称" : "";
  150. this.$util.toast(msg);
  151. }
  152. } else {
  153. if (!this.fileUrl) {
  154. this.$util.toast("请上传名片");
  155. return;
  156. }
  157. this.submitPost();
  158. }
  159. },
  160. async submitPost() {
  161. const res = await Mine.activity_signin_byHand({
  162. ActivityId: this.codeId, //活动ID
  163. CountryCode: this.countryCode, //区号
  164. Mobile: this.phoneNumber, //手机号
  165. VCode: this.phoneCode, //验证码
  166. CompanyName: this.corporateName, //公司名称
  167. BusinessCard: this.fileUrl, //名片地址
  168. RealName: this.userName, //姓名
  169. SigninType: Number(this.radioValue), //签到方式,1:填写手机号/机构名称;2:上传名片
  170. });
  171. if (res.Ret === 200) {
  172. this.$emit("getDetail");
  173. }
  174. },
  175. },
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .content-upload-contact {
  180. .show-mobile {
  181. display: flex;
  182. align-items: center;
  183. padding-left: 30rpx;
  184. position: absolute;
  185. width: 690rpx;
  186. height: 78rpx;
  187. background: #bfbfbf;
  188. border-radius: 8rpx;
  189. color: #333333;
  190. }
  191. .title {
  192. text-align: center;
  193. color: #fff;
  194. font-weight: 500;
  195. font-size: 42rpx;
  196. line-height: 60rpx;
  197. margin-bottom: 70rpx;
  198. }
  199. .class-radio {
  200. color: #fff;
  201. font-size: 32rpx;
  202. font-weight: normal;
  203. margin-right: 50rpx;
  204. }
  205. .active-radio {
  206. color: #caaf8b;
  207. }
  208. .content-bind {
  209. padding: 10rpx;
  210. margin-bottom: 50rpx;
  211. }
  212. .ipt-item {
  213. display: flex;
  214. align-items: center;
  215. font-size: 34rpx;
  216. height: 78rpx;
  217. margin-top: 30rpx;
  218. .item-label {
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. width: 167rpx;
  223. margin-right: 10rpx;
  224. height: 100%;
  225. background-color: #fff;
  226. color: #999;
  227. padding: 0 25rpx;
  228. border-radius: 8rpx;
  229. }
  230. input {
  231. flex: 1;
  232. background-color: $uni-bg-color;
  233. height: 100%;
  234. border-radius: 8rpx;
  235. padding-left: 30rpx;
  236. }
  237. .item-code {
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. width: 185rpx;
  242. height: 60rpx;
  243. border: 2rpx solid #caaf8b;
  244. border-radius: 4rpx;
  245. color: #caaf8b;
  246. font-size: 28rpx;
  247. margin-left: 10rpx;
  248. }
  249. }
  250. .button-bind {
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. width: 349rpx;
  255. height: 78rpx;
  256. background: linear-gradient(180deg, #e5cfb1 0%, #caaf8b 100%);
  257. border-radius: 4rpx;
  258. margin: 0 auto;
  259. color: #333333;
  260. font-weight: 500;
  261. font-size: 32rpx;
  262. }
  263. .upload-card {
  264. width: 690rpx;
  265. height: 431rpx;
  266. background: #333333;
  267. border: 4rpx solid #caaf8b;
  268. border-radius: 4rpx;
  269. margin: 25rpx auto 50rpx;
  270. display: flex;
  271. align-items: center;
  272. box-sizing: border-box;
  273. image {
  274. width: 100%;
  275. height: 100%;
  276. }
  277. .upload-content {
  278. width: 100%;
  279. color: #caaf8b;
  280. text {
  281. font-size: 80rpx;
  282. font-weight: 700;
  283. width: 100%;
  284. text-align: center;
  285. }
  286. text:last-child {
  287. font-weight: 400;
  288. font-size: 32rpx;
  289. }
  290. }
  291. }
  292. }
  293. </style>