consignee-edit.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="consignee-editor">
  3. <!-- 收件人姓名 -->
  4. <view class="form-row">
  5. <text class="form-label">收货人姓名</text>
  6. <input
  7. v-model="consigneeName"
  8. class="form-input"
  9. placeholder="请输入姓名"
  10. maxlength="30"
  11. />
  12. </view>
  13. <!-- 收件人电话 -->
  14. <view class="form-row">
  15. <text class="form-label">手机号</text>
  16. <input
  17. v-model="consigneePhone"
  18. class="form-input"
  19. placeholder="请输入手机号"
  20. type="number"
  21. maxlength="11"
  22. />
  23. </view>
  24. <!-- 收件人地址 -->
  25. <view class="form-row">
  26. <text class="form-label">收货地址</text>
  27. <input
  28. v-model="consigneeAddress"
  29. class="form-input"
  30. placeholder="请输入收货地址"
  31. maxlength="120"
  32. />
  33. </view>
  34. <!-- 手签名段(选填,符合水机购买 AC4.3 未签名仍可保存语义) -->
  35. <view class="form-row form-row-signature">
  36. <text class="form-label">手签名</text>
  37. <view class="signature-cell">
  38. <text v-if="handSignature" class="signature-set">已设置手签名</text>
  39. <text v-else class="placeholder">选填,可不上传</text>
  40. </view>
  41. </view>
  42. <view v-if="handSignature" class="signature-block">
  43. <image class="signature-preview-img" :src="handSignature" mode="widthFix" />
  44. </view>
  45. <view class="signature-block">
  46. <button class="btn-sign-entry" @click="goSignature">
  47. {{ handSignature ? '重新签名' : '去签名' }}
  48. </button>
  49. </view>
  50. <!-- 确认回调:收件人信息 + 手签名(选填)一并向上级确认 -->
  51. <view class="confirm-bar">
  52. <button class="btn-confirm" @click="onConfirm" @confirm="onConfirm">确认</button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import { setSignaturePrefill } from '@/utils/signature-bus.js'
  58. export default {
  59. name: 'ConsigneeEditor',
  60. props: {
  61. // 初始收件人信息({ name, phone, address, handSignature }),编辑场景由父级注入(子组件不自行请求接口)
  62. value: {
  63. type: Object,
  64. default: null
  65. }
  66. },
  67. data() {
  68. return {
  69. consigneeName: '',
  70. consigneePhone: '',
  71. consigneeAddress: '',
  72. handSignature: ''
  73. }
  74. },
  75. created() {
  76. var v = this.value || {}
  77. this.consigneeName = v.name || ''
  78. this.consigneePhone = v.phone || ''
  79. this.consigneeAddress = v.address || ''
  80. this.handSignature = v.handSignature || ''
  81. },
  82. methods: {
  83. // 去签名:当前签名经 signature-bus 预填 → 跳转独立横屏签名页;events.signatureConfirm 回传写回预览
  84. goSignature() {
  85. setSignaturePrefill(this.handSignature || '')
  86. uni.navigateTo({
  87. url: '/pages/signature/signature?requireAgree=1&agreeText=' + encodeURIComponent('我已阅读并同意,本人确认以上信息真实、准确'),
  88. events: {
  89. signatureConfirm: (dataUrl) => {
  90. this.handSignature = dataUrl || ''
  91. }
  92. }
  93. })
  94. },
  95. // 确认回调:手签名选填(未签名不拦截),向上级转发收件人信息与签名
  96. onConfirm() {
  97. var payload = {
  98. name: this.consigneeName,
  99. phone: this.consigneePhone,
  100. address: this.consigneeAddress,
  101. handSignature: this.handSignature
  102. }
  103. if (typeof this.$emit === 'function') {
  104. this.$emit('confirm', payload)
  105. }
  106. }
  107. }
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .consignee-editor {
  112. width: 100%;
  113. }
  114. .form-row {
  115. display: flex;
  116. align-items: center;
  117. padding: 24rpx 0;
  118. border-bottom: 1rpx solid $facade-fill-2;
  119. }
  120. .form-row:last-child {
  121. border-bottom: none;
  122. }
  123. .form-label {
  124. font-size: calc(28rpx * var(--font-scale, 1));
  125. color: $facade-text-strong;
  126. width: 180rpx;
  127. flex-shrink: 0;
  128. }
  129. .form-input {
  130. flex: 1;
  131. font-size: calc(28rpx * var(--font-scale, 1));
  132. color: $facade-text-strong;
  133. text-align: right;
  134. padding: 8rpx 0;
  135. }
  136. .form-row-signature {
  137. border-bottom: none;
  138. }
  139. .signature-cell {
  140. flex: 1;
  141. text-align: right;
  142. font-size: calc(28rpx * var(--font-scale, 1));
  143. color: $facade-text-strong;
  144. padding: 8rpx 0;
  145. }
  146. .signature-cell .placeholder {
  147. color: $facade-text-ghost;
  148. }
  149. .signature-set {
  150. color: $el-success;
  151. }
  152. .signature-block {
  153. padding: 0 0 24rpx;
  154. }
  155. .signature-preview-img {
  156. width: 100%;
  157. height: auto;
  158. background: $app-surface;
  159. border: 2rpx dashed $facade-text-ghost;
  160. border-radius: 16rpx;
  161. }
  162. .btn-sign-entry {
  163. width: 100%;
  164. height: 80rpx;
  165. line-height: 80rpx;
  166. padding: 0;
  167. background: linear-gradient(135deg, $accent-indigo, $accent-indigo-deep);
  168. color: $app-surface;
  169. border: none;
  170. border-radius: 24rpx;
  171. font-size: calc(28rpx * var(--font-scale, 1));
  172. text-align: center;
  173. }
  174. .btn-sign-entry::after {
  175. border: none;
  176. }
  177. .confirm-bar {
  178. padding-top: 40rpx;
  179. }
  180. .btn-confirm {
  181. width: 100%;
  182. height: 88rpx;
  183. line-height: 88rpx;
  184. padding: 0;
  185. background: linear-gradient(135deg, $accent-indigo, $accent-indigo-deep);
  186. color: $app-surface;
  187. border: none;
  188. border-radius: 24rpx;
  189. font-size: calc(30rpx * var(--font-scale, 1));
  190. text-align: center;
  191. }
  192. .btn-confirm::after {
  193. border: none;
  194. }
  195. </style>