You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
7.9 KiB

8 months ago
  1. <template>
  2. <view class="content">
  3. <view class="banner"></view>
  4. <view class="b-relative" style="width: 710rpx;height: 310rpx; margin: -174rpx auto 0;">
  5. <image src="/static/ms/settled.png" style="width: 710rpx;height: 310rpx;"></image>
  6. <view class="banner-font">
  7. <image style="width: 380rpx;height: 98rpx;" src="/static/ms/fontjszm.png"></image>
  8. </view>
  9. <view class="font-3">打造专业的技术服务</view>
  10. <view class="banner-button">立即联系我们>></view>
  11. </view>
  12. <view>
  13. <view class="item-card">
  14. <view class="item-line flex">
  15. <view class="before"></view>
  16. <view class="label">技师姓名</view>
  17. <input placeholder="请输入姓名" v-model="technician.name" />
  18. </view>
  19. <view class="item-line flex">
  20. <view class="before"></view>
  21. <view class="label">技师性别</view>
  22. <van-radio-group v-model="technician.sex" direction="horizontal">
  23. <van-radio name="男"></van-radio>
  24. <van-radio name="女"></van-radio>
  25. </van-radio-group>
  26. </view>
  27. <view class="item-line flex">
  28. <view class="before"></view>
  29. <view class="label">联系方式</view>
  30. <input placeholder="请输入联系方式" v-model="technician.phone" />
  31. </view>
  32. <view class="item-line flex">
  33. <view class="before"></view>
  34. <view class="label">技师年龄</view>
  35. <input placeholder="请输入技师年龄" type="number" v-model.number="technician.age" />
  36. </view>
  37. <view class="item-line flex">
  38. <view class="before"></view>
  39. <view class="label">意向城市</view>
  40. <input placeholder="请输入意向工作城市" v-model="technician.city" />
  41. </view>
  42. <view class="item-line flex">
  43. <view class="before"></view>
  44. <view class="label" style="width: 100%">请上传本人近期照片</view>
  45. </view>
  46. <view v-if="!technician.image" @click="fileUploads" class="upload">
  47. <uni-icons type="plusempty" size="80rpx" color="#37bea7"/>
  48. </view>
  49. <view v-else @click="fileUploads" class="upload b-relative">
  50. <image class="upload-img" :src="technician.image" mode="aspectFill"></image>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="b-fiexd">
  55. <view @click="addOrUpdateMsgTer" class="button-submit">提交</view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import OSS from "ali-oss"
  61. import { v4 as uuidv4 } from 'uuid';
  62. import { showDialog } from 'vant';
  63. export default {
  64. data() {
  65. return {
  66. technician: {
  67. id : '',
  68. name : '',
  69. sex : '男',
  70. phone : '',
  71. age : '',
  72. city : '',
  73. image : '',
  74. phone : ''
  75. },
  76. imgs : []
  77. }
  78. },
  79. onShow(){
  80. this.getTenFans()
  81. },
  82. methods: {
  83. getUserInfo() { //获取用户信息
  84. this.$api('getUserInfo', {}, res => {
  85. if (res.code == 200) {
  86. this.userInfo = res.result;
  87. }
  88. })
  89. },
  90. addOrUpdateMsgTer() { //新增修改技师入驻信息
  91. let isOk = this.parameterVerification()
  92. if(!isOk.auth){
  93. return uni.showToast({
  94. title : isOk.title,
  95. icon : 'none'
  96. })
  97. }
  98. this.$api('addOrUpdateMsgTer', this.technician, res => {
  99. if (res.code == 200) {
  100. showDialog({
  101. title: this.technician.id ? '修改入驻' : '技师入驻',
  102. message: this.technician.id ? '技师入驻修改成功' : '技师入驻提交成功',
  103. }).then(() => {
  104. uni.switchTab({
  105. url: '/pages/index/index'
  106. })
  107. });
  108. }
  109. })
  110. },
  111. parameterVerification(){ //验证用户参数合法性
  112. let { name , sex , phone , age , city , image } = this.technician
  113. if(name.trim() == ''){
  114. return { title : '请填写技师姓名' , auth : false }
  115. }else if(sex.trim() == ''){
  116. return { title : '请选择性别' , auth : false }
  117. }else if(phone.trim() == ''){
  118. return { title : '请填写手机号' , auth : false }
  119. }else if(!age){
  120. return { title : '请填写年龄' , auth : false }
  121. }else if(city.trim() == ''){
  122. return { title : '请填写意向城市' , auth : false }
  123. }else if(image.trim() == ''){
  124. return { title : '请上传近期照片' , auth : false }
  125. }else if(phone.trim() != ''){
  126. if(!this.$utils.verificationPhone(phone)){
  127. return { title : '手机号格式不合法' , auth : false }
  128. }
  129. }
  130. return { title : '验证通过' , auth : true }
  131. },
  132. fileUploads() { //上传文件
  133. uni.chooseImage({
  134. count: 1, // 默认9,设置为1表示单选
  135. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  136. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  137. success: (res) => {
  138. let resultPromise = [];
  139. //上传单张图片逻辑
  140. this.uploadFileToOSS(res.tempFiles[0]).then(imgPath => {
  141. this.technician.image = imgPath;
  142. })
  143. }
  144. });
  145. },
  146. getTenFans(){ //获取我推荐的技师记录
  147. this.$api('getTenFans', {}, res => {
  148. if (res.code == 200) {
  149. if(res.result.length > 0){
  150. let { id , name , sex , age , city , image , phone } = res.result[0];
  151. this.technician = { id ,name , sex , age , city , image , phone }
  152. }
  153. }
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. body {
  161. background-color: #f5f5f5;
  162. }
  163. .banner {
  164. width: 100vw;
  165. height: calc(392rpx - 160rpx);
  166. background: linear-gradient(38deg, #4899a6 44%, #60bda2 100%);
  167. }
  168. .banner-font {
  169. width: 292rpx;
  170. height: 142rpx;
  171. font-size: 72rpx;
  172. line-height: 66rpx;
  173. font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  174. font-weight: 400;
  175. text-align: left;
  176. color: #ffffff;
  177. letter-spacing: -1;
  178. text-shadow: 0px 6px 6px 0px rgba(0, 165, 141, 0.70);
  179. position: absolute;
  180. left: 52rpx;
  181. top: 34rpx;
  182. }
  183. .font-3 {
  184. height: 28rpx;
  185. line-height: 28rpx;
  186. font-size: 24rpx;
  187. font-family: PingFang SC, PingFang SC-Regular;
  188. font-weight: 400;
  189. text-align: left;
  190. color: #ffffff;
  191. text-shadow: 0 4rpx 6rpx 0 rgba(0, 165, 141, 0.70);
  192. position: absolute;
  193. left: 52rpx;
  194. top: 138rpx;
  195. }
  196. .banner-button {
  197. width: 240rpx;
  198. height: 56rpx;
  199. line-height: 56rpx;
  200. background: #ffdb75;
  201. border-radius: 24rpx;
  202. box-shadow: 0 6rpx 6rpx 0 rgba(17, 106, 93, 0.23);
  203. position: absolute;
  204. left: 52rpx;
  205. top: 220rpx;
  206. font-size: 24rpx;
  207. font-family: PingFang SC, PingFang SC-Bold;
  208. font-weight: 700;
  209. text-align: center;
  210. color: #26c591;
  211. }
  212. .item-card {
  213. width: calc(710rpx - 40rpx);
  214. height: 840rpx;
  215. background: #ffffff;
  216. border-radius: 16rpx;
  217. margin: 40rpx auto 20rpx;
  218. padding: 1rpx 20rpx;
  219. }
  220. .item-line {
  221. height: 60rpx;
  222. font-size: 28rpx;
  223. font-family: PingFang SC, PingFang SC-Bold;
  224. font-weight: 700;
  225. text-align: left;
  226. color: #333333;
  227. margin-top: 40rpx;
  228. }
  229. .item-line .before {
  230. content: "";
  231. width: 8rpx;
  232. height: 30rpx;
  233. background: #4fd3bc;
  234. border-radius: 4rpx;
  235. margin-right: 10rpx;
  236. margin-top: 15rpx;
  237. }
  238. .item-line .label {
  239. display: flex;
  240. align-items: center;
  241. width: 152rpx;
  242. height: 60rpx;
  243. }
  244. .item-line input {
  245. width: 456rpx;
  246. height: 60rpx;
  247. line-height: 60rpx;
  248. background: #f5f5f5;
  249. border-radius: 12rpx;
  250. font-size: 24rpx;
  251. font-family: PingFang SC, PingFang SC-Medium;
  252. font-weight: 500;
  253. text-align: left;
  254. color: #939393;
  255. padding: 0 20rpx;
  256. }
  257. .upload {
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. width: 200rpx;
  262. height: 200rpx;
  263. background: rgba(245, 245, 245, 0.82);
  264. border: 2rpx dashed #99dcd0;
  265. border-radius: 16rpx;
  266. margin: 10rpx 12rpx;
  267. }
  268. .upload-img{
  269. width: calc(100% - 4rpx);
  270. height: calc(100% - 4rpx);
  271. border: 2rpx dashed #ccc;
  272. margin: 2rpx;
  273. }
  274. .button-submit {
  275. display: flex;
  276. align-items: center;
  277. justify-content: center;
  278. width: 596rpx;
  279. height: 90rpx;
  280. background: linear-gradient(180deg, #6fdfbe, #5ac796);
  281. border-radius: 46rpx;
  282. margin: 20rpx auto;
  283. font-size: 28rpx;
  284. font-family: PingFang SC, PingFang SC-Regular;
  285. font-weight: 400;
  286. text-align: center;
  287. color: #ffffff;
  288. }
  289. </style>