金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
4.9 KiB

  1. <template>
  2. <view class="wallet_class">
  3. <view class="pay-pwd-input" v-if="pawType==='one'" :style="'width:' + width + 'rpx'" @tap="tokey">
  4. <view class="pay-pwd-grid uni-flex uni-row" v-for="(value, index) in payPwdGrid" :key="index">
  5. <view :style="('width:'+ width1 + 'rpx;') + ((focusType&&(index==list.length))?borderCheckStyle:'') ">{{value.text}}</view>
  6. </view>
  7. </view>
  8. <view class="input-row" v-if="pawType==='two'" :style="'width:' + width + 'rpx'" @tap="tokey">
  9. <view class="pay-pwd-grid uni-flex uni-row" v-for="(value, index) in payPwdGrid" :key="index">
  10. <view :class="'item'" :style="('width:'+ width1 + 'rpx;') + ((focusType&&(index==list.length))?borderCheckStyle:'') ">{{ value.text }}</view>
  11. </view>
  12. </view>
  13. <input v-if="keyType" :type="inputType" :style="'width:' + width + 'rpx'" :maxlength="places" class="input_info" @input="inputVal"
  14. @focus="focus" @blur="blur" />
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'wallet_category',
  20. props: {
  21. pawType: { //输入框样式
  22. type: String,
  23. default: 'one'
  24. },
  25. places: { // 密码框位数
  26. type: Number,
  27. default: 6
  28. },
  29. width: {
  30. type: Number,
  31. default: 750
  32. },
  33. borderCheckStyle: {
  34. type: String,
  35. default: 'border: 1px solid #f00;'
  36. },
  37. codes: {
  38. type: String,
  39. default: ''
  40. },
  41. keyType: {
  42. type: Boolean,
  43. default: true
  44. },
  45. isPwy:{
  46. type: Boolean,
  47. default: true
  48. },
  49. inputType:{
  50. type: String,
  51. default: 'number'
  52. }
  53. },
  54. data() {
  55. return {
  56. focusType: false,
  57. width1: 110,
  58. list: [],
  59. payPwdGrid: []
  60. }
  61. },
  62. mounted() {
  63. // 组件文档地址:https://ext.dcloud.net.cn/plugin?id=2695
  64. this.list = this.codes.split('')
  65. this.width1 = (this.width - 90) / this.places
  66. this.payPwdGrid = []
  67. for (let a = 0; a < this.places; a++) {
  68. this.payPwdGrid.push({
  69. text: ''
  70. })
  71. }
  72. if(this.isPwy){
  73. for (let a = 0; a < this.list.length; a++) {
  74. this.payPwdGrid[a].text = '●'
  75. }
  76. }else{
  77. for (let a = 0; a < this.list.length; a++) {
  78. this.payPwdGrid[a].text = this.list[a]
  79. }
  80. }
  81. },
  82. watch: {
  83. places() {
  84. this.list = this.codes.split('')
  85. this.width1 = (this.width - 90) / this.places
  86. this.payPwdGrid = []
  87. for (let a = 0; a < this.places; a++) {
  88. this.payPwdGrid.push({
  89. text: ''
  90. })
  91. }
  92. if(this.isPwy){
  93. for (let a = 0; a < this.list.length; a++) {
  94. this.payPwdGrid[a].text = '●'
  95. }
  96. }else{
  97. for (let a = 0; a < this.list.length; a++) {
  98. this.payPwdGrid[a].text = this.list[a]
  99. }
  100. }
  101. },
  102. codes() {
  103. this.list = this.codes.split('')
  104. this.payPwdGrid = []
  105. for (let a = 0; a < this.places; a++) {
  106. this.payPwdGrid.push({
  107. text: ''
  108. })
  109. }
  110. if(this.isPwy){
  111. for (let a = 0; a < this.list.length; a++) {
  112. this.payPwdGrid[a].text = '●'
  113. }
  114. }else{
  115. for (let a = 0; a < this.list.length; a++) {
  116. this.payPwdGrid[a].text = this.list[a]
  117. }
  118. }
  119. this.$emit('inputVal', this.codes);
  120. }
  121. },
  122. methods: {
  123. focus() {
  124. this.focusType = true
  125. },
  126. blur() {
  127. this.focusType = false
  128. },
  129. tokey(){
  130. this.$emit('tokey');
  131. },
  132. inputVal(e) {
  133. let inputValues = e.detail.value;
  134. this.list = inputValues.split('')
  135. this.payPwdGrid = []
  136. for (let a = 0; a < this.places; a++) {
  137. this.payPwdGrid.push({
  138. text: ''
  139. })
  140. }
  141. if(this.isPwy){
  142. for (let a = 0; a < this.list.length; a++) {
  143. this.payPwdGrid[a].text = '●'
  144. }
  145. }else{
  146. for (let a = 0; a < this.list.length; a++) {
  147. this.payPwdGrid[a].text = this.list[a]
  148. }
  149. }
  150. this.$emit('inputVal', inputValues);
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .wallet_class {
  157. position: relative;
  158. height: 100%;
  159. .pay-pwd-input {
  160. height: 100%;
  161. line-height: 100%;
  162. display: flex;
  163. justify-content: flex-start;
  164. .pay-pwd-grid {
  165. margin: 0upx auto;
  166. height: 100%;
  167. line-height: 100%;
  168. display: flex;
  169. justify-content: center;
  170. view {
  171. width: 110upx;
  172. height: 100%;
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. border: #cececd solid 0.1upx;
  177. border-radius: 10upx;
  178. font-size: 36upx;
  179. font-weight: 600;
  180. }
  181. .xaunz {
  182. border: #f00 solid 0.1upx;
  183. }
  184. }
  185. }
  186. .input-row {
  187. height: 100%;
  188. line-height: 100%;
  189. display: flex;
  190. justify-content: flex-start;
  191. .pay-pwd-grid {
  192. margin: 0upx auto;
  193. height: 100%;
  194. line-height: 100%;
  195. display: flex;
  196. justify-content: center;
  197. .item {
  198. width: 110rpx;
  199. height: 100%;
  200. display: flex;
  201. align-items: center;
  202. justify-content: center;
  203. font-size: 36upx;
  204. font-weight: 600;
  205. border-bottom: 1px solid #c8c8c8;
  206. }
  207. .item-active {
  208. position: relative;
  209. transform: scale(1.2);
  210. }
  211. }
  212. }
  213. .input_info {
  214. width: 1200rpx;
  215. height: 100%;
  216. line-height: 100%;
  217. opacity: 0;
  218. position: absolute;
  219. top: 0rpx;
  220. left: 0;
  221. }
  222. }
  223. </style>