applyTrial.vue 6.0 KB

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