| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <view class="">
- <NoData v-if="!signListInvoke.length"></NoData>
- <view class="page_v u-flex-col" v-else>
- <view v-for="(item,index) in signListInvoke" :key="index" :class="item.isDefault ? 'active' : '' "
- class="lists_box" @click="setMainSignInvoke(item,index)">
- <view class="signImgBox">
- <image :src="item.signImg" mode="scaleToFill" class="signImg"></image>
- </view>
- <view class="icon-checked-box" v-if="item.isDefault==1">
- <view class="icon-checked">
- <u-icon name="checkbox-mark" color="#fff" size="28"></u-icon>
- </view>
- </view>
- </view>
- </view>
- <!-- 底部按钮 -->
- <view class="flowBefore-actions">
- <u-button class="buttom-btn" @click.stop="eventLauncher('cancel')">{{$t('common.cancelText')}}</u-button>
- <u-button class="buttom-btn" type="primary" @click.stop="eventLauncher('confirm')">{{$t('common.okText')}}</u-button>
- </view>
- </view>
- </template>
- <script>
- import NoData from "@/components/noData";
- import {
- getSignImgList
- } from "@/api/common";
- export default {
- components: {
- NoData
- },
- data() {
- return {
- show: false,
- signListInvoke: [],
- };
- },
- async onLoad(config) {
- this.signListInvoke = await this.getSignData()
- this.clearChoose()
- let val = decodeURIComponent(config.signVal)
- if (val) {
- this.setMainSignInvokeWithValue(val)
- }
- uni.setStorageSync('sign-fieldKey', config.fieldKey)
- },
- methods: {
- getSignData() {
- return new Promise((resolve, reject) => {
- if (!this.signListInvoke.length) {
- getSignImgList().then(res => {
- resolve(res.data || [])
- })
- } else {
- resolve(this.signListInvoke)
- }
- })
- },
- clearChoose() {
- for (let i = 0; i < this.signListInvoke.length; i++) {
- let item = this.signListInvoke[i]
- item.isDefault = 0
- this.$set(this.signListInvoke, i, item)
- }
- },
- setMainSignInvokeWithValue(val) {
- for (let i = 0; i < this.signListInvoke.length; i++) {
- let item = this.signListInvoke[i]
- if (item.signImg === val) {
- this.setMainSignInvoke(item, i)
- break;
- }
- }
- },
- eventLauncher(type) {
- if (type === 'cancel') uni.navigateBack();
- if (type === 'confirm') {
- let choose = this.signListInvoke.filter(item => item.isDefault === 1)
- if (!choose || !choose.length) return this.$u.toast(`请选择签名`)
- this.$nextTick(() => uni.$emit('setSignValue', choose[0].signImg))
- uni.navigateBack()
- }
- },
- setMainSignInvoke(item, index) {
- this.clearChoose()
- item.isDefault = 1
- this.$set(this.signListInvoke, index, item)
- },
- }
- }
- </script>
- <style lang="scss">
- page {
- height: 100%;
- background-color: #f0f2f6;
- }
- .page_v {
- height: 100%;
- padding: 0 10px 60px;
- .active {
- border: 1rpx solid #2979FF;
- color: #2979FF;
- .icon-ym-organization {
- &::before {
- color: #2979FF !important;
- }
- }
- }
- .sign-mask {
- width: 100%;
- height: 200rpx;
- background: rgba(0, 0, 0, .3);
- position: absolute;
- top: 0;
- border-radius: 8rpx;
- display: flex;
- align-items: center;
- flex-direction: column;
- justify-content: center;
- .sign-mask-btn {
- width: 60%;
- display: flex;
- }
- }
- .lists_box {
- width: 100%;
- height: 200rpx;
- border-radius: 8rpx;
- position: relative;
- display: flex;
- flex-direction: column;
- justify-content: center;
- background-color: #FFFFFF;
- margin-top: 20rpx;
- .signImgBox {
- width: 100%;
- height: 100%;
- text-align: center;
- border-radius: 8rpx;
- .signImg {
- width: 100%;
- height: 100%;
- border-radius: 8rpx;
- }
- }
- .icon-checked-box {
- display: flex;
- width: 140rpx;
- height: 80rpx;
- position: absolute;
- transform: scale(0.9);
- right: -4rpx;
- bottom: -2rpx;
- flex-direction: row;
- align-items: center;
- .icon-checked {
- width: 44rpx;
- height: 44rpx;
- border: 40rpx solid #1890ff;
- border-left: 40rpx solid transparent;
- border-top: 40rpx solid transparent;
- border-bottom-right-radius: 12rpx;
- position: absolute;
- transform: scale(0.95);
- right: -8rpx;
- bottom: -6rpx;
- }
- }
- }
- }
- </style>
|