notice.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="acct-notice-page">
  3. <view class="acct-notice-nav" :style="{ paddingTop: statusBar + 'px' }">
  4. <view class="acct-notice-nav-row">
  5. <view class="acct-notice-back" @tap="goBack">
  6. <text class="acct-notice-back-icon">←</text>
  7. </view>
  8. <text class="acct-notice-nav-title">{{ copy.title }}</text>
  9. <view class="acct-notice-nav-placeholder" />
  10. </view>
  11. </view>
  12. <scroll-view
  13. scroll-y
  14. class="acct-notice-scroll"
  15. :style="{ height: scrollHeight + 'px' }"
  16. >
  17. <view class="acct-notice-body" :style="{ paddingBottom: safeBottom + 'px' }">
  18. <text class="acct-notice-section">{{ copy.section }}</text>
  19. <view class="acct-notice-card">
  20. <view class="acct-notice-row">
  21. <view class="acct-notice-row-text">
  22. <text class="acct-notice-row-title">{{ copy.banner }}</text>
  23. <text class="acct-notice-row-desc">{{ copy.bannerDesc }}</text>
  24. </view>
  25. <switch
  26. :class="user.pushs ? 'checked' : ''"
  27. :checked="user.pushs ? true : false"
  28. @change="handleSwitch('pushs', $event)"
  29. />
  30. </view>
  31. <view class="acct-notice-row">
  32. <view class="acct-notice-row-text">
  33. <text class="acct-notice-row-title">{{ copy.sound }}</text>
  34. <text class="acct-notice-row-desc">{{ copy.soundDesc }}</text>
  35. </view>
  36. <switch
  37. :class="user.voice ? 'checked' : ''"
  38. :checked="user.voice ? true : false"
  39. @change="handleSwitch('voice', $event)"
  40. />
  41. </view>
  42. <view class="acct-notice-row acct-notice-row--last">
  43. <view class="acct-notice-row-text">
  44. <text class="acct-notice-row-title">{{ copy.vibration }}</text>
  45. <text class="acct-notice-row-desc">{{ copy.vibrationDesc }}</text>
  46. </view>
  47. <switch
  48. :class="user.shock ? 'checked' : ''"
  49. :checked="user.shock ? true : false"
  50. @change="handleSwitch('shock', $event)"
  51. />
  52. </view>
  53. </view>
  54. <text class="acct-notice-hint">{{ copy.hint }}</text>
  55. </view>
  56. </scroll-view>
  57. </view>
  58. </template>
  59. <script>
  60. import { mapState } from 'vuex'
  61. export default {
  62. data() {
  63. return {
  64. statusBar: 0,
  65. scrollHeight: 600,
  66. safeBottom: 0
  67. }
  68. },
  69. computed: {
  70. ...mapState({
  71. user: state => state.user
  72. }),
  73. copy() {
  74. const t = this.$t.bind(this)
  75. return {
  76. title: t('user.panelNewMessage'),
  77. section: t('user.noticeSection'),
  78. banner: t('user.noticeBanner'),
  79. bannerDesc: t('user.noticeBannerDesc'),
  80. sound: t('user.noticeSound'),
  81. soundDesc: t('user.noticeSoundDesc'),
  82. vibration: t('user.noticeVibration'),
  83. vibrationDesc: t('user.noticeVibrationDesc'),
  84. hint: t('user.noticeHint')
  85. }
  86. }
  87. },
  88. onLoad() {
  89. const sys = uni.getSystemInfoSync()
  90. this.statusBar = sys.statusBarHeight || 0
  91. this.safeBottom = sys.safeAreaInsets ? sys.safeAreaInsets.bottom : 0
  92. const navH = this.statusBar + uni.upx2px(88)
  93. this.scrollHeight = (sys.windowHeight || 667) - navH
  94. },
  95. methods: {
  96. goBack() {
  97. if (getCurrentPages().length > 1) {
  98. uni.navigateBack({ delta: 1 })
  99. } else {
  100. uni.switchTab({
  101. url: '/pages/mine/index',
  102. fail: () => uni.reLaunch({ url: '/pages/mine/index' })
  103. })
  104. }
  105. },
  106. handleSwitch(key, e) {
  107. const value = e.target.value
  108. this.$store.commit('user/apply', { [key]: value })
  109. uni.setStorageSync('wanlshop:user', this.$store.state.user)
  110. }
  111. }
  112. }
  113. </script>
  114. <style scoped>
  115. .acct-notice-page {
  116. min-height: 100vh;
  117. background-color: #f4f6fb;
  118. }
  119. .acct-notice-nav {
  120. background-color: #ffffff;
  121. border-bottom: 1rpx solid #eef1f6;
  122. }
  123. .acct-notice-nav-row {
  124. display: flex;
  125. flex-direction: row;
  126. align-items: center;
  127. height: 88rpx;
  128. padding: 0 24rpx;
  129. box-sizing: border-box;
  130. }
  131. .acct-notice-back {
  132. width: 64rpx;
  133. height: 64rpx;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. }
  138. .acct-notice-back-icon {
  139. font-size: 40rpx;
  140. color: #1a1d26;
  141. line-height: 1;
  142. }
  143. .acct-notice-nav-title {
  144. flex: 1;
  145. text-align: center;
  146. font-size: 32rpx;
  147. font-weight: 600;
  148. color: #1a1d26;
  149. }
  150. .acct-notice-nav-placeholder {
  151. width: 64rpx;
  152. }
  153. .acct-notice-body {
  154. padding: 24rpx 28rpx 0;
  155. box-sizing: border-box;
  156. }
  157. .acct-notice-section {
  158. display: block;
  159. padding: 0 8rpx 16rpx;
  160. font-size: 26rpx;
  161. color: #8a8d9e;
  162. }
  163. .acct-notice-card {
  164. background-color: #ffffff;
  165. border-radius: 24rpx;
  166. box-shadow: 0 6rpx 24rpx rgba(74, 140, 255, 0.06);
  167. overflow: hidden;
  168. margin-bottom: 20rpx;
  169. }
  170. .acct-notice-row {
  171. display: flex;
  172. flex-direction: row;
  173. align-items: center;
  174. justify-content: space-between;
  175. min-height: 120rpx;
  176. padding: 24rpx 28rpx;
  177. border-bottom: 1rpx solid #f0f2f7;
  178. box-sizing: border-box;
  179. }
  180. .acct-notice-row--last {
  181. border-bottom-width: 0;
  182. }
  183. .acct-notice-row-text {
  184. flex: 1;
  185. padding-right: 24rpx;
  186. }
  187. .acct-notice-row-title {
  188. display: block;
  189. font-size: 30rpx;
  190. font-weight: 500;
  191. color: #1a1d26;
  192. line-height: 1.35;
  193. }
  194. .acct-notice-row-desc {
  195. display: block;
  196. margin-top: 8rpx;
  197. font-size: 24rpx;
  198. line-height: 1.45;
  199. color: #8a8d9e;
  200. }
  201. .acct-notice-hint {
  202. display: block;
  203. padding: 0 8rpx;
  204. font-size: 24rpx;
  205. line-height: 1.5;
  206. color: #8a8d9e;
  207. }
  208. </style>