openService.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="wrap">
  3. <view class="content">
  4. <view class="row row-bottom">
  5. <view class="left">姓名</view>
  6. <input v-model="personInfo.name" class="right-bottom" placeholder="请输入姓名"></input>
  7. </view>
  8. <view class="row row-bottom">
  9. <view class="left">电话</view>
  10. <input class="right-bottom" v-model="personInfo.mobilePhone" placeholder="请输入电话"></input>
  11. </view>
  12. <view class="row no-boder">
  13. <view class="left">留言</view>
  14. </view>
  15. <view class="row no-boder">
  16. <u-input v-model="personInfo.message" :type="type" :border="border" :height="height"
  17. :auto-height="autoHeight" />
  18. </view>
  19. <view class="bottom">
  20. <u-button type="primary" class="submit" hover-class="none" @click="submit">提交</u-button>
  21. </view>
  22. </view>
  23. <u-toast ref="uToast" />
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState
  29. } from 'vuex';
  30. export default {
  31. components: {
  32. },
  33. data() {
  34. return {
  35. personInfo: {
  36. name: '',
  37. mobilePhone: '',
  38. message: '',
  39. type: 1
  40. },
  41. type: 'textarea',
  42. border: true,
  43. height: 150,
  44. autoHeight: true,
  45. }
  46. },
  47. onLoad() {
  48. },
  49. // #ifndef MP
  50. onNavigationBarButtonTap(e) {
  51. const index = e.index;
  52. if (index === 0) {
  53. this.navTo('/pages/set/set');
  54. } else if (index === 1) {
  55. // #ifdef APP-PLUS
  56. const pages = getCurrentPages();
  57. const page = pages[pages.length - 1];
  58. const currentWebview = page.$getAppWebview();
  59. currentWebview.hideTitleNViewButtonRedDot({
  60. index
  61. });
  62. // #endif
  63. uni.navigateTo({
  64. url: '/pages/notice/notice'
  65. })
  66. }
  67. },
  68. // #endif
  69. computed: {
  70. ...mapState(['hasLogin', 'userInfo']),
  71. },
  72. onShow() {
  73. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  74. console.log("checkSession", res)
  75. if (res.data.data == "INVALID") {
  76. uni.showModal({
  77. title: '登录提示',
  78. content: 'Session过期需要重新登录,是否立即登录?',
  79. showCancel: true,
  80. confirmText: '登录',
  81. success: (e) => {
  82. if (e.confirm) {
  83. uni.navigateTo({
  84. url: '/pages/public/login'
  85. })
  86. }
  87. },
  88. fail: () => {},
  89. complete: () => {}
  90. })
  91. }
  92. })
  93. console.log("hasLogin", this.hasLogin)
  94. },
  95. methods: {
  96. /**
  97. * 统一跳转接口,拦截未登录路由
  98. * navigator标签现在默认没有转场动画,所以用view
  99. */
  100. navTo(url) {
  101. if (!this.hasLogin) {
  102. url = '/pages/public/login';
  103. }
  104. uni.navigateTo({
  105. url
  106. })
  107. },
  108. calculate() {},
  109. submit() {
  110. if (!this.personInfo.name) {
  111. this.$refs.uToast.show({
  112. title: '姓名不能为空!',
  113. type: 'error',
  114. })
  115. }
  116. if (!this.personInfo.mobilePhone) {
  117. this.$refs.uToast.show({
  118. title: '电话号码不能为空!',
  119. type: 'error',
  120. })
  121. }
  122. this.$api.doRequest('post', '/openServiceInfo/api/addInfo', this.personInfo).then(res => {
  123. if (res.data.code == 200) {
  124. this.$refs.uToast.show({
  125. title: '提交成功,客服人员会及时与您取得联系。!',
  126. type: 'success',
  127. back: true
  128. })
  129. }
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang='scss' scoped>
  136. page {
  137. background: #F5F6FA;
  138. overflow: hidden;
  139. }
  140. .wrap {
  141. background: #fff;
  142. margin: 10px;
  143. border-radius: 10px;
  144. padding: 20rpx;
  145. }
  146. .content {
  147. border-radius: 20rpx;
  148. background: white;
  149. padding: 20rpx;
  150. .row {
  151. display: flex;
  152. justify-content: space-between;
  153. border-bottom: 1px solid #EEEEEE;
  154. padding: 21rpx 0;
  155. .right,
  156. input {
  157. font-size: 28rpx;
  158. color: #333333;
  159. }
  160. }
  161. .row-bottom {
  162. .right-bottom {
  163. width: 300rpx;
  164. text-align: right;
  165. }
  166. }
  167. .no-boder {
  168. border: 0;
  169. }
  170. }
  171. .submit {
  172. margin-top: 200rpx;
  173. background: #22C572;
  174. border-radius: 10rpx;
  175. }
  176. </style>