applyTrial.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="applyTrial-container container">
  3. <view class="applyTrial-content">
  4. <view class="tip">请上传您的名片信息,以便工作人员更好地为您服务</view>
  5. <view class="apply-top">
  6. <view class="add_icon upload-ico" v-if="!fileList.length" @click="ChooseFile">
  7. <u-icon name="plus" color="#9C9C9C" size="48"></u-icon>
  8. <text class="add-tip">上传图片</text>
  9. </view>
  10. <view class="add_icon" v-for="(item, index) in fileList" :key="item" v-else>
  11. <image class="img" :src="item" @click="viewImage(item, fileList)"> </image>
  12. <icon type="clear" size="16" class="del-ico" color="#f00" @click.stop="delImg(index)" />
  13. </view>
  14. <view class="card_default_cont">
  15. <image :src="img" mode="" class="card_default" @click="viewImage(img, img.split())"></image>
  16. <text class="tip">名片示例</text>
  17. </view>
  18. </view>
  19. <view class="apply-info-cont">
  20. <view class="ipt-item">
  21. <label class="item-label">姓名</label>
  22. <input type="text" v-model="name" class="ipt" placeholder="请输入姓名" />
  23. </view>
  24. <view class="ipt-item">
  25. <label class="item-label">公司名</label>
  26. <input type="text" v-model="company" class="ipt" placeholder="请输入公司名" />
  27. </view>
  28. <view class="ipt-item">
  29. <label class="item-label">手机号</label>
  30. <input type="number" v-model="mobile" class="ipt" maxlength="11" disabled />
  31. </view>
  32. <view class="btn-cont" @click="applyHandle"> 提交 </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { uploadurl, Mine, User } from "@/config/api.js";
  39. export default {
  40. data() {
  41. return {
  42. action: "",
  43. name: "",
  44. mobile: "",
  45. company: "",
  46. img: "https://hongze.oss-accelerate.aliyuncs.com/static/images/202102/20210219/gYD8azAtSeVzL8ZMbAu9mCyCxcTF.png",
  47. fileList: [], //名片列表
  48. tryType: "",
  49. detailId: 0,
  50. };
  51. },
  52. onLoad(op) {
  53. if (this.$db.get("mobile")) {
  54. this.mobile = this.$db.get("mobile");
  55. } else {
  56. this.getPhone();
  57. }
  58. this.tryType = op.tryType || "";
  59. this.detailId = op.detailId || 0;
  60. },
  61. methods: {
  62. /* 获取手机号 */
  63. getPhone() {
  64. Mine.getInfo().then((res) => {
  65. if (res.Ret === 200) {
  66. this.mobile = res.Data.Mobile;
  67. res.Data.Mobile && this.$db.set("mobile", res.Data.Mobile);
  68. }
  69. });
  70. },
  71. /* 上传图片 */
  72. ChooseFile() {
  73. this.$util.upload.Single(uploadurl, (res) => {
  74. let data = JSON.parse(res.data);
  75. if (data.Ret === 200) {
  76. this.fileList = data.Data.ResourceUrl.split();
  77. }
  78. });
  79. },
  80. /* 提交 */
  81. applyHandle() {
  82. if (this.name && this.company && this.fileList.length) {
  83. User.applyTry({
  84. ApplyMethod: 2,
  85. BusinessCardUrl: this.fileList.join(","),
  86. CompanyName: this.company,
  87. RealName: this.name,
  88. TryType: this.tryType,
  89. DetailId: this.detailId > 0 ? Number(this.detailId) : 0,
  90. }).then((res) => {
  91. if (res.Ret === 200) {
  92. uni.redirectTo({
  93. url: "/pageMy/applyResult/applyResult",
  94. });
  95. }
  96. });
  97. } else {
  98. this.$util.toast(`请${!this.fileList.length ? "上传名片" : !this.name ? "输入姓名" : !this.company ? "输入公司名" : ""}`);
  99. }
  100. },
  101. // 预览图片
  102. viewImage(path, imgList) {
  103. uni.previewImage({
  104. current: path, // 当前显示图片的http链接
  105. urls: imgList, // 需要预览的图片http链接列表
  106. });
  107. },
  108. // 删除图片
  109. delImg(index) {
  110. uni.showModal({
  111. title: "",
  112. content: "确定要删除图片吗 ?",
  113. success: (res) => {
  114. if (res.confirm) {
  115. this.fileList.splice(index, 1);
  116. }
  117. },
  118. });
  119. },
  120. },
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. .applyTrial-container {
  125. background-color: $uni-color-new;
  126. padding: 35rpx 30rpx;
  127. .applyTrial-content {
  128. background-color: #fff;
  129. padding: 50rpx 30rpx;
  130. border-radius: 8rpx;
  131. }
  132. .tip {
  133. padding: 11rpx 32rpx;
  134. color: #b2b2b2;
  135. font-size: 24rpx;
  136. }
  137. .apply-top {
  138. padding: 30rpx 0;
  139. display: flex;
  140. justify-content: space-between;
  141. align-items: center;
  142. .add_icon {
  143. width: 330rpx;
  144. height: 200rpx;
  145. position: relative;
  146. .del-ico {
  147. position: absolute;
  148. right: 20rpx;
  149. top: 20rpx;
  150. }
  151. .img {
  152. width: 330rpx;
  153. height: 200rpx;
  154. }
  155. &.upload-ico {
  156. padding-top: 50rpx;
  157. text-align: center;
  158. background-color: $uni-bg-color;
  159. color: #4a4a4a;
  160. margin-right: 20rpx;
  161. .add-tip {
  162. margin-top: 10rpx;
  163. }
  164. }
  165. }
  166. .card_default_cont {
  167. position: relative;
  168. .card_default {
  169. width: 330rpx;
  170. height: 200rpx;
  171. display: block;
  172. }
  173. .tip {
  174. background-color: rgba($color: #000000, $alpha: 0.5);
  175. border-radius: 8rpx;
  176. padding: 12rpx 22rpx;
  177. color: #fff;
  178. font-size: 24rpx;
  179. position: absolute;
  180. right: 0;
  181. bottom: 0;
  182. z-index: 1;
  183. }
  184. }
  185. }
  186. .apply-info-cont {
  187. .ipt-item {
  188. padding: 33rpx 0;
  189. border-bottom: 1rpx solid #e5e5e5;
  190. display: flex;
  191. align-items: center;
  192. font-size: 34rpx;
  193. .item-label {
  194. text-align: justify;
  195. text-align-last: justify;
  196. display: inline-block;
  197. width: 106rpx;
  198. margin-right: 40rpx;
  199. }
  200. .ipt {
  201. width: 500rpx;
  202. font-size: 32rpx;
  203. color: #666;
  204. }
  205. }
  206. .btn-cont {
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. width: 504rpx;
  211. height: 60rpx;
  212. color: #fff;
  213. border-radius: 8rpx;
  214. margin: 100rpx auto 0;
  215. background-color: #376cbb;
  216. }
  217. }
  218. }
  219. </style>