index.vue 6.8 KB

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