remark.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="remark-container">
  3. <view class="remark-select" @tap.stop.prevent="onRemarkClick">
  4. <view class="title">选择备注</view>
  5. <view class="remark-list">
  6. <view class="remark-item" :data-remark="item" @tap.stop.prevent="remarkItemSelect"
  7. v-for="(item, index) in remarkList" :key="index">
  8. <view class="remark-value">{{ item }}</view>
  9. <image mode="aspectFit" src="https://mall.zhaijieshi.cc/file/wx-dy/yd.png" class="radio-img"
  10. v-if="remarkActive == item"></image>
  11. <image mode="aspectFit" src="https://jzmall.lifejingzhi.com/file/jzmall-dy/icon-unselect-popup.png"
  12. class="radio-img" v-else></image>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="textarea-wrapper">
  17. <textarea placeholder="其他备注请填写" @tap="setTextareaFocus" :focus="isTextareaFocused" class="remark-extra"
  18. :value="message" @input="bindMessageInput" maxlength="200"
  19. placeholder-style="font-size:24rpx;color: #A5A5A5; letter-spacing: 2rpx; font-family: AlibabaPuHuiTi_2_65_Medium;" />
  20. <text class="remaining ">{{message.length}}/{{maxLength}}</text>
  21. </view>
  22. <view class="remark-conf-btn" @tap.stop.prevent="remarkItemConfirm">提交备注</view>
  23. </view>
  24. </template>
  25. <script>
  26. var util = require('@/utils/util.js');
  27. export default {
  28. data() {
  29. return {
  30. remark: '',
  31. remarkPopupShow: false,
  32. remarkList: ['上门前提前电话联系', '请准时到达', '请自带打扫工具', '主要打扫厨房&卫生间', '家里有宠物'],
  33. remarkActive: '',
  34. message: '',
  35. maxLength: 200, // 最大长度,
  36. isTextareaFocused: false,
  37. cursorPosition:''
  38. }
  39. },
  40. onShow() {
  41. let remark = uni.getStorageSync('remark')
  42. let remarkMsg = uni.getStorageSync('remarkMsg')
  43. if (remark) {
  44. this.setData({
  45. remark: remark,
  46. remarkActive: remark
  47. })
  48. }
  49. if (remarkMsg) {
  50. this.setData({
  51. message: remarkMsg
  52. })
  53. }
  54. },
  55. methods: {
  56. setTextareaFocus() {
  57. this.isTextareaFocused = true;
  58. },
  59. bindMessageInput(e) {
  60. this.setData({
  61. message: e.detail.value,
  62. cursorPosition:e.detail.cursor
  63. });
  64. uni.setStorageSync('remarkMsg', this.message)
  65. },
  66. onRemarkClick() {
  67. //阻止事件冒泡,不要删
  68. },
  69. remarkItemSelect(e) {
  70. let remark = e.currentTarget.dataset.remark;
  71. this.setData({
  72. remark: remark,
  73. remarkActive: remark
  74. });
  75. // console.log("remark",remark,this.remarkActive);
  76. uni.setStorageSync('remark', this.remark)
  77. },
  78. remarkItemConfirm() {
  79. uni.navigateBack()
  80. }
  81. }
  82. }
  83. </script>
  84. <style>
  85. .remark-container {
  86. font-family: AlibabaPuHuiTi_2_65_Medium;
  87. }
  88. .remaining {
  89. position: absolute;
  90. right: 24rpx;
  91. bottom: 20rpx;
  92. color: #A5A5A5;
  93. }
  94. .textarea-wrapper {
  95. min-height: 300rpx;
  96. border-radius: 16rpx;
  97. background-color: #ffffff;
  98. padding: 24rpx 24rpx 20rpx;
  99. display: flex;
  100. /* align-items: center; */
  101. width: 690rpx;
  102. margin: 10rpx 30rpx;
  103. position: relative;
  104. }
  105. .remark-extra {
  106. width: 642rpx;
  107. font-size: 26rpx;
  108. /* height:130rpx; */
  109. }
  110. .remark-select {
  111. width: 690rpx;
  112. /* padding: 0 24rpx 56rpx; */
  113. background: #ffffff;
  114. border-radius: 16rpx;
  115. padding: 10rpx 24rpx;
  116. margin: 30rpx auto 20rpx;
  117. }
  118. .remark-select .title {
  119. font-weight: 600;
  120. color: #191919;
  121. font-size: 30rpx;
  122. height: 90rpx;
  123. line-height: 90rpx;
  124. }
  125. .remark-item .remark-value {
  126. color: #191919;
  127. font-size: 26rpx;
  128. font-weight: bold;
  129. flex: 1;
  130. text-align: left;
  131. }
  132. .remark-list .remark-item {
  133. height: 84rpx;
  134. display: flex;
  135. /* border-bottom: 2rpx solid #e0e0e0; */
  136. align-items: center;
  137. }
  138. .remark-item .radio-img {
  139. width: 26rpx;
  140. height: 26rpx;
  141. }
  142. .remark-conf-btn {
  143. width: 690rpx;
  144. height: 90rpx;
  145. line-height: 90rpx;
  146. border-radius: 16rpx;
  147. text-align: center;
  148. font-size: 36rpx;
  149. background-color: #FE2C55;
  150. color: #fff;
  151. margin: 0 auto;
  152. margin-top: 54rpx;
  153. }
  154. </style>