123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <!-- 电子签名 -->
- <template>
- <view id="signature">
- <view class="signature_li">
- <view class="signature_li_t">示例:</view>
- <view class="signature_li_b">
- <img :src="imagesUrl('commonality/img_dzqm_sl.png')">
- </view>
- </view>
- <view class="tip">请上传白字黑子正楷签名</view>
- <view class="signature_li">
- <view class="signature_li_t">上传签名:</view>
- <view class="signature_li_b">
- <view class="signature_li_b_c" @click="selectImage"><span v-if="!signatureData">点击上传签名</span></view>
- <img class=".signature_li_img2" :src="signatureData">
- </view>
- <view class="clear_signature" @tap="signatureDele()">
- <img class="clear_signature_img" :src="imagesUrl('commonality/icon_sczl_sc.png')" />
- <text>清除</text>
- </view>
- <view class="upload_tip">请严格按照示例上传正楷签名并置于框内</view>
- </view>
- <view class="signature_li">
- <view class="signature_li_t" style="margin-top: 20rpx;">已上传的签名:</view>
- <image class="signature_li_img" :src="alreadyImg"></image>
- </view>
- <view class="save_btn" @click="saveFun()">保存</view>
- </view>
- </template>
- <script>
- import {
- config
- } from '@/api/request/config.js'
- import {
- updateSignature
- } from '@/pages_basics/api/index.js'
- export default {
- data() {
- return {
- baseUrl: config.base_url,
- signatureData: '',
- alreadyImg: '',
- }
- },
- onLoad(option) {
- //首次进入获取上个页面传过来的签名
- this.alreadyImg = this.baseUrl + option.item;
- console.log(this.alreadyImg)
- },
- onShow() {
- //用户点击上传签名
- if (uni.getStorageSync('signatureData')) {
- this.signatureData = uni.getStorageSync('signatureData');
- uni.removeStorageSync('signatureData');
- }
- },
- methods: {
- //清除签名
- async signatureDele() {
- let _this = this;
- this.signatureData = '';
- },
- //保存按钮
- async saveFun() {
- let _this = this;
- if (!this.signatureData) {
- uni.showToast({
- title: '请先选择签名上传并保存查看',
- icon: "none",
- mask: true,
- duration: 2000
- });
- return
- }
- var arr = this.signatureData.split(',')
- let obj = {
- signature: arr[1]
- }
- const {
- data
- } = await updateSignature(obj);
- if (data.code == 200) {
- uni.showToast({
- title: '上传成功',
- icon: "none",
- mask: true,
- duration: 2000
- });
- setTimeout(function() {
- uni.navigateBack()
- }, 2000);
- // uni.switchTab({
- // url: '/pages/mine'
- // });
- }
- },
- // 头像上传
- selectImage() {
- let self = this;
- wx.chooseImage({
- count: 1,
- sizeType: ["original", "compressed"],
- sourceType: ["album", "camera"],
- success: function(res) {
- console.log("res1", res)
- let tempFilePaths = res.tempFilePaths[0];
- self.uploadImg(tempFilePaths);
- }
- });
- },
- async uploadImg(tempFilePaths) {
- var self = this;
- uni.showLoading({
- title: '上传中',
- mask: true
- });
- uni.uploadFile({
- url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
- header: {
- 'Authorization': uni.getStorageSync('token')
- },
- filePath: tempFilePaths,
- name: 'file',
- formData: {
- 'user': 'test'
- },
- success: (uploadFileRes) => {
- let res = JSON.parse(uploadFileRes.data);
- if (res.code == 200) {
- uni.navigateTo({
- url: '/pages_basics/views/signature/signatureImg?src=' + config
- .base_url + res.data.url, //电子签名-图片处理
- });
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none",
- mask: true,
- duration: 2000
- });
- }
- },
- fail: err => {},
- complete: () => {
- uni.hideLoading()
- }
- });
- },
- },
- }
- </script>
- <style lang="stylus" scoped>
- #signature {
- width: 710rpx;
- height: auto;
- background: #FFFFFF;
- border-radius: 20rpx;
- margin: 20rpx 20rpx 0;
- padding: 28rpx 20rpx 94rpx;
- box-sizing: border-box;
- .tip {
- width: 100%;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- line-height: 24rpx;
- margin: 24rpx 0 42rpx 0;
- text-align: center;
- }
- .signature_li {
- .signature_li_t {
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- line-height: 28rpx;
- }
- .signature_li_b {
- position: relative;
- margin-top: 28rpx;
- width: 668rpx;
- height: 250rpx;
- background: #FFFFFF;
- border: 1px solid #E0E0E0;
- border-radius: 10rpx;
- text-align: center;
- >img {
- display: inline-block;
- width: 192rpx;
- height: 60rpx;
- margin-top: 90rpx;
- }
- .signature_li_b_c {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #0183FA;
- line-height: 250rpx;
- cursor: pointer;
- position: relative;
- z-index: 200;
- }
- .signature_li_img2 {
- position: absolute;
- left: 0;
- top: 0;
- z-index: 100;
- width: 668rpx;
- height: 250rpx;
- margin: 0;
- }
- }
- .signature_li_img {
- margin-top: 28rpx;
- width: 668rpx;
- height: 250rpx;
- background: #FFFFFF;
- border: 1px solid #E0E0E0;
- border-radius: 10rpx;
- text-align: center;
- }
- .upload_tip {
- width: 100%;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- line-height: 24rpx;
- margin: 24rpx 0 42rpx 0;
- text-align: center;
- }
- .clear_signature {
- height: 30rpx;
- margin: 20rpx 0;
- display: flex;
- justify-content: flex-end;
- .clear_signature_img {
- width: 30rpx;
- height: 30rpx;
- margin-right: 10rpx;
- }
- >text {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #A2A2A2;
- line-height: 30rpx;
- }
- }
- }
- /* 保存按钮*/
- .save_btn {
- width: 650rpx;
- height: 100rpx;
- background: #0183FA;
- border-radius: 20px;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 100rpx;
- text-align: center;
- margin-top: 44rpx;
- }
- }
- </style>
|