index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container" :style="{'height':'100vh'}">
  3. <!-- 提示内容 -->
  4. <view class="h-title">
  5. <text>*请选择1张服务对象照片</text>
  6. </view>
  7. <view class="h-upload-wrap">
  8. <view class="h-item-row">
  9. <view @click="uploadImg()" class="h-item">
  10. <view v-if="!facePhotoUrl" class="h-content">
  11. <image src="/static/me/u01.png" mode="aspectFill"></image>
  12. <view class="h-text">
  13. <text>添加照片</text>
  14. </view>
  15. </view>
  16. <view v-else class="h-upload-img">
  17. <image mode="aspectFit" class="imgBox" :src="facePhotoUrl"></image>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 保存备案信息 -->
  23. <view class="uploadBox" @click="verifyFace()">
  24. <text>下一步</text>
  25. </view>
  26. <view class="btnTitle flex-row">
  27. <u-icon v-if="selectIcon" name="checkmark-circle-fill" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  28. <u-icon v-else name="/static/order/ud9.png" color="#FFE52C" size="18" @click="selectChange"></u-icon>
  29. <text :style="{'margin-left':'10rpx'}">请阅读并同意</text>
  30. <text :style="{'color':'red'}" @click="goTermsOfService">《服务对象协议》</text>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. components: {
  37. },
  38. data() {
  39. return {
  40. requestStatus:false,
  41. selectIcon:false,
  42. ossId:'',
  43. facePhotoUrl:'',
  44. height:'',
  45. reqParm: {
  46. auth: true,
  47. facePath: '',
  48. businessId: ''
  49. },
  50. userInfo: {},
  51. }
  52. },
  53. onReady() {
  54. },
  55. onLoad(option) {
  56. },
  57. methods: {
  58. goTermsOfService(){
  59. uni.navigateTo({
  60. url:'/myPages/TermsOfService/index?name='+'服务对象协议'+'&type=' + 6
  61. })
  62. },
  63. selectChange(){
  64. this.selectIcon = !this.selectIcon
  65. },
  66. // 连接已上传的图片地址
  67. verifyImgUpload(){
  68. if(!this.ossId){
  69. uni.showToast({
  70. title: "请上传人脸照片"
  71. })
  72. return false;
  73. }
  74. return true;
  75. },
  76. // 验证人象
  77. verifyFace(){
  78. let that = this;
  79. if(!this.selectIcon){
  80. uni.$u.toast('请阅读并同意《服务对象协议》')
  81. return;
  82. }
  83. // 验证图片是否全上传
  84. if(!that.verifyImgUpload()){
  85. return;
  86. }
  87. uni.showLoading({
  88. title: '人脸识别中'
  89. })
  90. if(this.requestStatus){
  91. return;
  92. }
  93. this.requestStatus=true
  94. this.$api.verifyFace(that.reqParm).then((res)=>{
  95. this.requestStatus=false
  96. uni.hideLoading();
  97. if(res.data.data.code == '500'){ //人脸不存在
  98. let serviceObject = {}
  99. serviceObject.facePhoto= this.ossId
  100. serviceObject.facePhotoUrl=this.facePhotoUrl
  101. console.log(JSON.stringify(serviceObject))
  102. uni.redirectTo({
  103. url: '/myPages/serviceObjectAllInfo/index?data='+ JSON.stringify(serviceObject),
  104. })
  105. } else { // 人脸存在
  106. let serviceObject = res.data.data
  107. serviceObject.opType = "1";
  108. serviceObject.facePhotoUrl = that.facePhotoUrl;
  109. serviceObject.facePhoto = that.reqParm.facePath;
  110. uni.redirectTo({
  111. url: '/myPages/serviceObjectInfo/index?data=' + JSON.stringify(serviceObject),
  112. })
  113. }
  114. }).catch((err) =>{
  115. this.requestStatus=false
  116. uni.$u.toast('识别失败,请重新上传照片')
  117. });
  118. },
  119. //头像上传
  120. uploadImg() {
  121. let that = this;
  122. uni.chooseImage({
  123. count: 1,
  124. success: (chooseImageRes) => {
  125. const tempFilePaths = chooseImageRes.tempFilePaths;
  126. uni.uploadFile({
  127. url: that.$baseUrl + '/resource/oss/upload', //仅为示例,非真实的接口地址
  128. filePath: tempFilePaths[0],
  129. name: 'file',
  130. header: {
  131. 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
  132. },
  133. success: (uploadFileRes) => {
  134. console.log("uploadFileRes:"+uploadFileRes)
  135. let res = JSON.parse(uploadFileRes.data)
  136. that.ossId = res.data.ossId;
  137. that.facePhotoUrl = res.data.url.replace("http", "https");
  138. that.reqParm.facePath = res.data.ossId;
  139. }
  140. });
  141. }
  142. });
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .container{
  149. padding: 12px;
  150. background: #F6F6F6;
  151. }
  152. .h-title{
  153. height: 22px;
  154. font-size: 14px;
  155. font-family: PingFangSC-Regular, PingFang SC;
  156. font-weight: 400;
  157. color: #333333;
  158. line-height: 22px;
  159. }
  160. // 弹窗
  161. .h-popo-content{
  162. height: 170px;
  163. padding: 12px;
  164. width: 300px;
  165. text-align: center;
  166. font-size: 14px;
  167. font-family: PingFangSC-Semibold, PingFang SC;
  168. .h-img{
  169. display: flex;
  170. justify-content: center;
  171. }
  172. .h-text{
  173. margin-top: 12px;
  174. font-weight: 400;
  175. color: #666666;
  176. }
  177. .text{
  178. margin-top: 6px;
  179. font-weight: 400;
  180. color: #666666;
  181. }
  182. .h-btn-wrap{
  183. display: flex;
  184. justify-content: space-between;
  185. color: #333333;
  186. text-align: center;
  187. margin-top: 20px;
  188. .h-left-btn{
  189. height: 32px;
  190. line-height: 30px;
  191. background: #EEEEEE;
  192. width: 100px;
  193. text-align: center;
  194. border-radius: 16px;
  195. margin: 0 auto;
  196. }
  197. .h-right-btn{
  198. height: 32px;
  199. line-height: 30px;
  200. background: #FFE05C;
  201. width: 100px;
  202. border-radius: 16px;
  203. margin: 0 auto;
  204. }
  205. }
  206. }
  207. .h-upload-wrap{
  208. .h-item-row{
  209. width: 100%;
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. margin-top: 12px;
  214. font-family: PingFangSC-Regular, PingFang SC;
  215. .h-item{
  216. background: #fff;
  217. width: 48%;
  218. text-align: center;
  219. height: 164px;
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. border-radius: 6px;
  224. .h-content{
  225. image{
  226. height: 48px;
  227. width: 48px;
  228. }
  229. .h-text{
  230. margin-top: 10px;
  231. font-size: 12px;
  232. font-weight: 400;
  233. color: #999999;
  234. line-height: 20px;
  235. }
  236. }
  237. .h-upload-img{
  238. width: 100%;
  239. height: 164px;
  240. padding: 4px;
  241. .imgBox{
  242. width: 164px;
  243. height: 164px;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. .uploadBox {
  250. width: 100%;
  251. margin-top: 30px;
  252. height: 42px;
  253. background: #FFE05C;
  254. border-radius: 27px;
  255. color: #333333;
  256. line-height: 42px;
  257. text-align: center;
  258. }
  259. .btnTitle{
  260. font-size: 24rpx;
  261. font-weight: 400;
  262. color: #333333;
  263. line-height: 50px;
  264. padding-left: 32rpx;
  265. }
  266. @import '/common/css/common.css';
  267. </style>