shoprz.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="content ">
  3. <view class="item-name">
  4. 工资认证
  5. </view>
  6. <view class="listBox">
  7. <view class="con_box">
  8. <view class="tip">
  9. 请上传最近3单工资证明
  10. </view>
  11. <view class="con_image" v-for="(item,ind) in updata.service_audit_imgs">
  12. <image class="img" @click="navCroper(400,400,'audit',ind)" :src="item"></image>
  13. <image @click="updata.service_audit_imgs.splice(ind,1)" class="tip"
  14. src="../../../static/icon/goodsExit.png" mode="scaleToFill"></image>
  15. </view>
  16. <view class="con_image">
  17. <image class="img" @click="navCroper(400,400,'auditall')" src="../../../static/image/upImg.png">
  18. </image>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="item-name">
  23. 企业认证
  24. </view>
  25. <view class="listBox">
  26. <view class="con_box">
  27. <input type="text" placeholder="请输入认证企业名称" v-model="store_name">
  28. </view>
  29. </view>
  30. <view class="base-buttom" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. subTypeAudit
  36. } from '@/api/model.js';
  37. import {
  38. mapState
  39. } from "vuex"
  40. export default {
  41. data() {
  42. return {
  43. // 上传数据
  44. updata: {
  45. service_audit_imgs: [], //服务图片
  46. },
  47. loding: false, //是否载入中
  48. store_name: ''
  49. };
  50. },
  51. onLoad(options) {
  52. this.init()
  53. },
  54. computed: {
  55. // #ifdef H5
  56. ...mapState(['urlFile']),
  57. // #endif
  58. ...mapState(['baseURL']),
  59. },
  60. methods: {
  61. // 初始化
  62. init() {
  63. const that = this;
  64. },
  65. upLoad(path) {
  66. // #ifdef H5
  67. console.log(path, 'h5');
  68. // #endif
  69. uni.showLoading({
  70. title: '图片上传中',
  71. mask: true
  72. });
  73. return new Promise((resolve, error) => {
  74. uni.uploadFile({
  75. url: this.baseURL + '/api/user/qiniuUpload', //仅为示例,非真实的接口地址
  76. filePath: path,
  77. name: 'file',
  78. header: {
  79. "token": uni.getStorageSync('token')
  80. },
  81. success: (uploadFileRes) => {
  82. if ("string" === typeof uploadFileRes.data) {
  83. resolve(JSON.parse(uploadFileRes.data).data)
  84. } else {
  85. resolve(uploadFileRes.data.data)
  86. }
  87. },
  88. complete() {
  89. uni.hideLoading()
  90. }
  91. });
  92. })
  93. },
  94. // 图片裁切
  95. /**
  96. * @param {Number} w 裁切宽度比例
  97. * @param {Number} h 裁切高度比例
  98. * @param {Number} mw 图片最小宽度
  99. * @param {Number} mh 图片最小高度
  100. * @param {String} url url修改
  101. */
  102. navCroper(w, h, type, ind) {
  103. let that = this;
  104. let tt = (type == 'upimg' ? 2 : 1)
  105. this.onImg(tt).then((url) => {
  106. uni.navigateTo({
  107. url: `../realName/cropper?width=${w}&height=${h}`,
  108. events: {
  109. uploadSuccess(res) {
  110. that.upLoad(res).then((urldata) => {
  111. if (type == 'audit') {
  112. that.updata.service_audit_imgs.splice(ind, 1, urldata.img)
  113. } else if (type == 'auditall') {
  114. that.updata.service_audit_imgs.push(urldata.img)
  115. }
  116. })
  117. }
  118. },
  119. success: function(res) {
  120. // 通过eventChannel向被打开页面传送数据
  121. res.eventChannel.emit('urlNext', {
  122. url
  123. })
  124. }
  125. })
  126. })
  127. },
  128. onImg(type) {
  129. const _this = this
  130. return new Promise((ok, erro) => {
  131. // 判断是否需要选择
  132. if (type == 1) {
  133. uni.showActionSheet({
  134. itemList: ['拍照', '选择一张照片'],
  135. success: function(res) {
  136. _this.chooseImage(res.tapIndex).then((url) => {
  137. ok(url)
  138. }).catch((res) => {
  139. erro(res)
  140. })
  141. },
  142. fail: function(res) {
  143. erro(res)
  144. console.log(res.errMsg);
  145. }
  146. });
  147. }
  148. // 判断是否只需要拍照
  149. if (type == 2) {
  150. _this.chooseImage(0).then((url) => {
  151. ok(url)
  152. }).catch((res) => {
  153. erro(res)
  154. })
  155. }
  156. })
  157. },
  158. chooseImage: function(index) {
  159. const _this = this
  160. return new Promise((ok, error) => {
  161. // 从相册/相机选择
  162. // 如需直接开相机或直接选相册,请只使用一个选项
  163. const sourceType = index === 0 ? ['camera'] : ['album']
  164. uni.chooseImage({
  165. count: 1, //默认9
  166. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  167. sourceType: sourceType,
  168. success: function(res) {
  169. ok(res.tempFilePaths[0])
  170. },
  171. fail(e) {
  172. uni.showModal({
  173. title: '文件打开错误',
  174. content: '请设置授权文件存储权限',
  175. showCancel: false,
  176. });
  177. error(e)
  178. }
  179. });
  180. })
  181. },
  182. // 实名认证
  183. confirm(e) {
  184. const that = this;
  185. if (that.updata.service_audit_imgs.length == 0) {
  186. uni.showModal({
  187. title: '错误',
  188. content: '请上传工资截图',
  189. showCancel: false,
  190. });
  191. return
  192. }
  193. // if(that.store_name == '' ) {
  194. // uni.showModal({
  195. // title: '错误',
  196. // content: '请输入企业名称',
  197. // showCancel: false,
  198. // });
  199. // return
  200. // }
  201. that.loding = true;
  202. subTypeAudit({
  203. service_audit_imgs: that.updata.service_audit_imgs,
  204. store_name: that.store_name
  205. })
  206. .then((e) => {
  207. that.loding = false;
  208. this.$api.msg(e.msg);
  209. })
  210. .catch(err => {
  211. this.loding = false;
  212. console.log(err);
  213. });
  214. }
  215. }
  216. };
  217. </script>
  218. <style lang="scss">
  219. .content,
  220. page {
  221. min-height: 100%;
  222. }
  223. .content {
  224. padding-bottom: 150rpx;
  225. }
  226. .item-name {
  227. margin: $page-row-spacing;
  228. font-size: $font-lg;
  229. font-weight: bold;
  230. color: $font-color-dark;
  231. }
  232. .con_box {
  233. margin: $page-row-spacing;
  234. .tip {
  235. color: #999999;
  236. font-size: $font-base;
  237. margin-bottom: 20rpx;
  238. }
  239. .con_image {
  240. width: 150rpx;
  241. height: 150rpx;
  242. display: inline-block;
  243. margin-right: 20rpx;
  244. position: relative;
  245. .img {
  246. width: 100%;
  247. height: 100%;
  248. }
  249. .tip {
  250. position: absolute;
  251. top: -10rpx;
  252. right: -10rpx;
  253. width: 30rpx;
  254. height: 30rpx;
  255. background-color: #FFF;
  256. border-radius: 99rpx;
  257. }
  258. }
  259. }
  260. .listBox {
  261. margin: $page-row-spacing;
  262. margin-top: 30rpx;
  263. border-radius: 20rpx;
  264. overflow: hidden;
  265. background-color: #FFFFFF;
  266. }
  267. .list {
  268. .input {
  269. text-align: right;
  270. font-size: $font-base;
  271. color: $color-gray;
  272. width: 100%;
  273. }
  274. .listItem {
  275. padding: 35rpx 40rpx;
  276. border-bottom: 1px solid $page-color-light;
  277. }
  278. .listIconImg {
  279. width: 36rpx;
  280. }
  281. .right {
  282. color: $font-color-light;
  283. font-size: $font-base;
  284. flex-grow: 1;
  285. justify-content: flex-end;
  286. .timetype {
  287. width: 100%;
  288. justify-content: flex-end;
  289. }
  290. .citylist {
  291. .del {
  292. color: $color-red;
  293. font-size: $font-sm;
  294. border: 1px solid $color-red;
  295. border-radius: 10rpx;
  296. line-height: 1;
  297. padding: 5rpx 15rpx;
  298. }
  299. }
  300. .img {
  301. width: 26rpx;
  302. }
  303. .buttom {
  304. color: $base-color;
  305. border: 1px solid $base-color;
  306. border-radius: 10rpx;
  307. line-height: 1;
  308. padding: 10rpx 20rpx;
  309. }
  310. }
  311. .titleBox {
  312. .title {
  313. color: $font-color-base;
  314. font-size: $font-base;
  315. }
  316. }
  317. }
  318. .bg-gray {
  319. background-color: $color-gray;
  320. }
  321. .base-buttom {
  322. position: fixed;
  323. bottom: 30rpx;
  324. right: 0rpx;
  325. left: 0rpx;
  326. }
  327. </style>