attestation.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="content">
  3. <view class="yz-wrap">
  4. <view class="top-wrap flex">
  5. <view class="top-left">
  6. 选择套餐<text>*</text>
  7. </view>
  8. </view>
  9. <view class="sr-wrap flex">
  10. <view class="sr-tit">
  11. 姓名
  12. </view>
  13. <input type="text" class="sr-inp" placeholder="请输入姓名">
  14. </view>
  15. <view class="sr-wrap flex">
  16. <view class="sr-tit">
  17. 手机号
  18. </view>
  19. <input type="text" class="sr-inp" placeholder="请输入手机号">
  20. </view>
  21. <view class="sr-wrap flex">
  22. <view class="sr-tit">
  23. 验证码
  24. </view>
  25. <input type="text" class="sr-inp" placeholder="请输入验证码">
  26. <view class="sr-btn">
  27. 点击获取
  28. </view>
  29. </view>
  30. </view>
  31. <view class="yz-wrap">
  32. <view class="top-wrap flex">
  33. <view class="top-left">
  34. 上传身份证照片<text>*</text>
  35. </view>
  36. </view>
  37. <view class="sfz flex">
  38. <!-- #ifdef H5 -->
  39. <image class="" :src="sfzz||this.urlFile + '/static/img/sfzz.png'" mode="widthFix" @click="navCroper(664,414,'sfzz')"></image>
  40. <!-- #endif -->
  41. <!-- #ifndef H5 -->
  42. <image class="" :src="sfzz||'/static/img/sfzz.png'" mode="widthFix" @click="navCroper(664,414,'sfzz')"></image>
  43. <!-- #endif -->
  44. <!-- #ifdef H5 -->
  45. <image class="" :src="sfzf||this.urlFile + '/static/img/sfzf.png'" mode="widthFix" @click="navCroper(664,414,'sfzf')"></image>
  46. <!-- #endif -->
  47. <!-- #ifndef H5 -->
  48. <image class="" :src="sfzf||'/static/img/sfzf.png'" mode="widthFix" @click="navCroper(664,414,'sfzf')"></image>
  49. <!-- #endif -->
  50. <view class="">
  51. 个人信息面
  52. </view>
  53. <view class="">
  54. 国徽面
  55. </view>
  56. </view>
  57. </view>
  58. <view class="yz-wrap">
  59. <view class="sr-wrap flex">
  60. <view class="sr-tit">
  61. 绑定邀请码
  62. </view>
  63. <input type="text" class="sr-inp" placeholder="请输入绑定邀请码(非必填)">
  64. </view>
  65. </view>
  66. <view class="btm-btn">
  67. 提交认证
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. mapState
  74. } from "vuex"
  75. export default {
  76. data() {
  77. return {
  78. sfzz: '',
  79. sfzf: ''
  80. }
  81. },
  82. onLoad() {
  83. },
  84. onShow() {
  85. },
  86. computed: {
  87. // #ifdef H5
  88. ...mapState(['urlFile']),
  89. // #endif
  90. },
  91. onReachBottom() {
  92. },
  93. onReady() {
  94. },
  95. methods: {
  96. upLoad(path) {
  97. // #ifdef H5
  98. console.log(path,'h5');
  99. // #endif
  100. uni.showLoading({
  101. title: '图片上传中',
  102. mask: true
  103. });
  104. return new Promise((resolve, error) => {
  105. uni.uploadFile({
  106. url: this.baseURL + '/api/upload/image', //仅为示例,非真实的接口地址
  107. filePath: path,
  108. name: 'file',
  109. header: {
  110. "Authori-zation": 'Bearer ' + uni.getStorageSync('token')
  111. },
  112. success: (uploadFileRes) => {
  113. if ("string" === typeof uploadFileRes.data) {
  114. resolve(JSON.parse(uploadFileRes.data).data)
  115. } else {
  116. resolve(uploadFileRes.data.data)
  117. }
  118. },
  119. complete() {
  120. uni.hideLoading()
  121. }
  122. });
  123. })
  124. },
  125. chooseImage: function(index) {
  126. const _this = this
  127. return new Promise((ok, error) => {
  128. // 从相册/相机选择
  129. // 如需直接开相机或直接选相册,请只使用一个选项
  130. const sourceType = index === 0 ? ['camera'] : ['album']
  131. uni.chooseImage({
  132. count: 1, //默认9
  133. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  134. sourceType: sourceType,
  135. success: function(res) {
  136. ok(res.tempFilePaths[0])
  137. },
  138. fail(e) {
  139. uni.showModal({
  140. title: '文件打开错误',
  141. content: '请设置授权文件存储权限',
  142. showCancel: false,
  143. });
  144. error(e)
  145. }
  146. });
  147. })
  148. },
  149. onImg(type) {
  150. const _this = this
  151. return new Promise((ok, erro) => {
  152. // 判断是否需要选择
  153. if(type==1){
  154. uni.showActionSheet({
  155. itemList: ['拍照', '选择一张照片'],
  156. success: function(res) {
  157. _this.chooseImage(res.tapIndex).then((url) => {
  158. ok(url)
  159. }).catch((res) => {
  160. erro(res)
  161. })
  162. },
  163. fail: function(res) {
  164. erro(res)
  165. console.log(res.errMsg);
  166. }
  167. });
  168. }
  169. // 判断是否只需要拍照
  170. if(type==2){
  171. _this.chooseImage(0).then((url) => {
  172. ok(url)
  173. }).catch((res) => {
  174. erro(res)
  175. })
  176. }
  177. })
  178. },
  179. // 图片裁切
  180. /**
  181. * @param {Number} w 裁切宽度比例
  182. * @param {Number} h 裁切高度比例
  183. * @param {Number} mw 图片最小宽度
  184. * @param {Number} mh 图片最小高度
  185. * @param {String} url url修改
  186. */
  187. navCroper(w, h, type) {
  188. let that = this;
  189. let tt = (type == 'upimg' ? 2 : 1)
  190. this.onImg(tt).then((url) => {
  191. uni.navigateTo({
  192. url: `/pages/user_home/realName/cropper?width=${w}&height=${h}`,
  193. events: {
  194. uploadSuccess(res) {
  195. that.upLoad(res).then((urldata) => {
  196. that[type] = urldata.url;
  197. })
  198. // console.log(e, '接受数据');
  199. }
  200. },
  201. success: function(res) {
  202. console.log(res,'success');
  203. // 通过eventChannel向被打开页面传送数据
  204. res.eventChannel.emit('urlNext', {
  205. url
  206. })
  207. }
  208. })
  209. })
  210. },
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. page {
  216. padding-top: 1rpx;
  217. }
  218. .yz-wrap {
  219. background-color: #fff;
  220. margin: 20rpx 0;
  221. }
  222. .top-wrap {
  223. justify-content: space-between;
  224. padding: 0 25rpx;
  225. font-size: 32rpx;
  226. font-weight: bold;
  227. color: #00001A;
  228. height: 85rpx;
  229. .top-left {
  230. text {
  231. color: #FF6B2E;
  232. margin-left: 10rpx;
  233. }
  234. }
  235. .top-right {
  236. text {
  237. font-size: 25rpx;
  238. font-weight: 500;
  239. color: #999999;
  240. }
  241. image {
  242. height: 22rpx;
  243. margin-left: 10rpx;
  244. }
  245. }
  246. }
  247. .sr-wrap {
  248. border-top: #fafafa 1rpx solid;
  249. font-size: 32rpx;
  250. font-weight: 500;
  251. width: 690rpx;
  252. height: 114rpx;
  253. line-height: 114rpx;
  254. margin: auto;
  255. .sr-tit {
  256. width: 170rpx;
  257. flex-shrink: 0;
  258. color: #00001A;
  259. }
  260. .sr-inp {
  261. flex-grow: 1;
  262. }
  263. .sr-btn {
  264. color: #52C696;
  265. }
  266. }
  267. .sfz {
  268. padding: 30rpx;
  269. justify-content: space-between;
  270. flex-wrap: wrap;
  271. image {
  272. width: 332rpx;
  273. height: 207rpx;
  274. }
  275. view {
  276. width: 332rpx;
  277. text-align: center;
  278. font-size: 32rpx;
  279. color: #5C5C5C;
  280. }
  281. }
  282. .btm-btn {
  283. width: 686rpx;
  284. height: 86rpx;
  285. background: linear-gradient(-38deg, #6CDBC3, #6DD6B8);
  286. border-radius: 15rpx;
  287. margin: 113rpx auto 0;
  288. font-size: 36rpx;
  289. font-weight: 500;
  290. color: #FFFFFF;
  291. text-align: center;
  292. line-height: 86rpx;
  293. }
  294. </style>