link-edit.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="link-edit-container" v-if="showPopup">
  3. <view class="link-edit">
  4. <view class="title">添加链接</view>
  5. <view class="edit">
  6. <view class="description">
  7. 链接描述:
  8. <input v-model="descVal" type="text" class="input" placeholder="请输入链接描述" />
  9. </view>
  10. <view class="address">
  11. 链接地址:
  12. <input v-model="addrVal" type="text" class="input" placeholder="请输入链接地址" />
  13. </view>
  14. </view>
  15. <view class="control">
  16. <view class="cancel" @click="close">取消</view>
  17. <view class="confirm" @click="onConfirm">确认</view>
  18. </view>
  19. </view>
  20. <view class="mask"></view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. showPopup: false,
  28. descVal: '',
  29. addrVal: ''
  30. }
  31. },
  32. methods: {
  33. open() {
  34. this.showPopup = true
  35. this.$emit('open')
  36. },
  37. close() {
  38. this.showPopup = false
  39. this.descVal = ''
  40. this.addrVal = ''
  41. this.$emit('close')
  42. },
  43. onConfirm() {
  44. if (!this.descVal) {
  45. uni.showToast({
  46. title: '请输入链接描述',
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. if (!this.addrVal) {
  52. uni.showToast({
  53. title: '请输入链接地址',
  54. icon: 'none'
  55. })
  56. return
  57. }
  58. this.$emit('confirm', {
  59. text: this.descVal,
  60. href: this.addrVal
  61. })
  62. this.close()
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .link-edit-container {
  69. .link-edit {
  70. width: 80%;
  71. position: absolute;
  72. top: 50%;
  73. left: 50%;
  74. transform: translate(-50%, -50%);
  75. background-color: #ffffff;
  76. box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05), 2px 2px 4px rgba(0, 0, 0, 0.05);
  77. border-radius: 12rpx;
  78. box-sizing: border-box;
  79. z-index: 999;
  80. font-size: 14px;
  81. .title {
  82. height: 80rpx;
  83. display: flex;
  84. justify-content: center;
  85. align-items: center;
  86. }
  87. .edit {
  88. padding: 24rpx;
  89. border-top: 1px solid #eeeeee;
  90. border-bottom: 1px solid #eeeeee;
  91. box-sizing: border-box;
  92. .input {
  93. flex: 1;
  94. padding: 4px;
  95. font-size: 14px;
  96. border: 1px solid #eeeeee;
  97. border-radius: 8rpx;
  98. .uni-input-placeholder {
  99. color: #dddddd;
  100. }
  101. }
  102. .description {
  103. display: flex;
  104. align-items: center;
  105. }
  106. .address {
  107. display: flex;
  108. align-items: center;
  109. margin-top: 24rpx;
  110. }
  111. }
  112. .control {
  113. height: 80rpx;
  114. display: flex;
  115. cursor: pointer;
  116. .cancel {
  117. flex: 1;
  118. color: #dd524d;
  119. display: flex;
  120. justify-content: center;
  121. align-items: center;
  122. }
  123. .confirm {
  124. border-left: 1px solid #eeeeee;
  125. flex: 1;
  126. color: #007aff;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. }
  131. }
  132. }
  133. .mask {
  134. position: absolute;
  135. top: 0;
  136. left: 0;
  137. right: 0;
  138. bottom: 0;
  139. background-color: rgba(0, 0, 0, 0.05);
  140. z-index: 998;
  141. }
  142. }
  143. </style>