signInvokeList.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="">
  3. <NoData v-if="!signListInvoke.length"></NoData>
  4. <view class="page_v u-flex-col" v-else>
  5. <view v-for="(item,index) in signListInvoke" :key="index" :class="item.isDefault ? 'active' : '' "
  6. class="lists_box" @click="setMainSignInvoke(item,index)">
  7. <view class="signImgBox">
  8. <image :src="item.signImg" mode="scaleToFill" class="signImg"></image>
  9. </view>
  10. <view class="icon-checked-box" v-if="item.isDefault==1">
  11. <view class="icon-checked">
  12. <u-icon name="checkbox-mark" color="#fff" size="28"></u-icon>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 底部按钮 -->
  18. <view class="flowBefore-actions">
  19. <u-button class="buttom-btn" @click.stop="eventLauncher('cancel')">{{$t('common.cancelText')}}</u-button>
  20. <u-button class="buttom-btn" type="primary" @click.stop="eventLauncher('confirm')">{{$t('common.okText')}}</u-button>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import NoData from "@/components/noData";
  26. import {
  27. getSignImgList
  28. } from "@/api/common";
  29. export default {
  30. components: {
  31. NoData
  32. },
  33. data() {
  34. return {
  35. show: false,
  36. signListInvoke: [],
  37. };
  38. },
  39. async onLoad(config) {
  40. this.signListInvoke = await this.getSignData()
  41. this.clearChoose()
  42. let val = decodeURIComponent(config.signVal)
  43. if (val) {
  44. this.setMainSignInvokeWithValue(val)
  45. }
  46. uni.setStorageSync('sign-fieldKey', config.fieldKey)
  47. },
  48. methods: {
  49. getSignData() {
  50. return new Promise((resolve, reject) => {
  51. if (!this.signListInvoke.length) {
  52. getSignImgList().then(res => {
  53. resolve(res.data || [])
  54. })
  55. } else {
  56. resolve(this.signListInvoke)
  57. }
  58. })
  59. },
  60. clearChoose() {
  61. for (let i = 0; i < this.signListInvoke.length; i++) {
  62. let item = this.signListInvoke[i]
  63. item.isDefault = 0
  64. this.$set(this.signListInvoke, i, item)
  65. }
  66. },
  67. setMainSignInvokeWithValue(val) {
  68. for (let i = 0; i < this.signListInvoke.length; i++) {
  69. let item = this.signListInvoke[i]
  70. if (item.signImg === val) {
  71. this.setMainSignInvoke(item, i)
  72. break;
  73. }
  74. }
  75. },
  76. eventLauncher(type) {
  77. if (type === 'cancel') uni.navigateBack();
  78. if (type === 'confirm') {
  79. let choose = this.signListInvoke.filter(item => item.isDefault === 1)
  80. if (!choose || !choose.length) return this.$u.toast(`请选择签名`)
  81. this.$nextTick(() => uni.$emit('setSignValue', choose[0].signImg))
  82. uni.navigateBack()
  83. }
  84. },
  85. setMainSignInvoke(item, index) {
  86. this.clearChoose()
  87. item.isDefault = 1
  88. this.$set(this.signListInvoke, index, item)
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. page {
  95. height: 100%;
  96. background-color: #f0f2f6;
  97. }
  98. .page_v {
  99. height: 100%;
  100. padding: 0 10px 60px;
  101. .active {
  102. border: 1rpx solid #2979FF;
  103. color: #2979FF;
  104. .icon-ym-organization {
  105. &::before {
  106. color: #2979FF !important;
  107. }
  108. }
  109. }
  110. .sign-mask {
  111. width: 100%;
  112. height: 200rpx;
  113. background: rgba(0, 0, 0, .3);
  114. position: absolute;
  115. top: 0;
  116. border-radius: 8rpx;
  117. display: flex;
  118. align-items: center;
  119. flex-direction: column;
  120. justify-content: center;
  121. .sign-mask-btn {
  122. width: 60%;
  123. display: flex;
  124. }
  125. }
  126. .lists_box {
  127. width: 100%;
  128. height: 200rpx;
  129. border-radius: 8rpx;
  130. position: relative;
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: center;
  134. background-color: #FFFFFF;
  135. margin-top: 20rpx;
  136. .signImgBox {
  137. width: 100%;
  138. height: 100%;
  139. text-align: center;
  140. border-radius: 8rpx;
  141. .signImg {
  142. width: 100%;
  143. height: 100%;
  144. border-radius: 8rpx;
  145. }
  146. }
  147. .icon-checked-box {
  148. display: flex;
  149. width: 140rpx;
  150. height: 80rpx;
  151. position: absolute;
  152. transform: scale(0.9);
  153. right: -4rpx;
  154. bottom: -2rpx;
  155. flex-direction: row;
  156. align-items: center;
  157. .icon-checked {
  158. width: 44rpx;
  159. height: 44rpx;
  160. border: 40rpx solid #1890ff;
  161. border-left: 40rpx solid transparent;
  162. border-top: 40rpx solid transparent;
  163. border-bottom-right-radius: 12rpx;
  164. position: absolute;
  165. transform: scale(0.95);
  166. right: -8rpx;
  167. bottom: -6rpx;
  168. }
  169. }
  170. }
  171. }
  172. </style>