openService.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. isShowAlert: false,
  36. content: '当前登入信息验证失败,是否重新登录?',
  37. personInfo: {
  38. name: '',
  39. mobilePhone: '',
  40. message: '',
  41. type: 1
  42. },
  43. type: 'textarea',
  44. border: true,
  45. height: 150,
  46. autoHeight: true,
  47. }
  48. },
  49. onLoad() {
  50. },
  51. // #ifndef MP
  52. onNavigationBarButtonTap(e) {
  53. const index = e.index;
  54. if (index === 0) {
  55. this.navTo('/pages/set/set');
  56. } else if (index === 1) {
  57. // #ifdef APP-PLUS
  58. const pages = getCurrentPages();
  59. const page = pages[pages.length - 1];
  60. const currentWebview = page.$getAppWebview();
  61. currentWebview.hideTitleNViewButtonRedDot({
  62. index
  63. });
  64. // #endif
  65. uni.navigateTo({
  66. url: '/pages/notice/notice'
  67. })
  68. }
  69. },
  70. // #endif
  71. computed: {
  72. ...mapState(['hasLogin', 'userInfo']),
  73. },
  74. onShow() {
  75. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  76. console.log("checkSession", res)
  77. if (res.data.data == "INVALID") {
  78. this.isShowAlert = true;
  79. // uni.showModal({
  80. // title: '登录提示',
  81. // content: '当前登入信息验证失败,是否重新登录?',
  82. // showCancel: true,
  83. // confirmText: '登录',
  84. // success: (e) => {
  85. // if (e.confirm) {
  86. // uni.navigateTo({
  87. // url: '/pages/public/login'
  88. // })
  89. // }
  90. // },
  91. // fail: () => {},
  92. // complete: () => {}
  93. // })
  94. }
  95. })
  96. console.log("hasLogin", this.hasLogin)
  97. },
  98. methods: {
  99. /**
  100. * 统一跳转接口,拦截未登录路由
  101. * navigator标签现在默认没有转场动画,所以用view
  102. */
  103. navTo(url) {
  104. if (!this.hasLogin) {
  105. url = '/pages/public/login';
  106. }
  107. uni.navigateTo({
  108. url
  109. })
  110. },
  111. alertBtn() {
  112. uni.navigateTo({
  113. url: '/pages/public/login'
  114. })
  115. },
  116. cancelClick() {
  117. this.isShowAlert = false
  118. },
  119. calculate() {},
  120. submit() {
  121. if (!this.personInfo.name) {
  122. this.$refs.uToast.show({
  123. title: '姓名不能为空!',
  124. type: 'error',
  125. })
  126. }
  127. if (!this.personInfo.mobilePhone) {
  128. this.$refs.uToast.show({
  129. title: '电话号码不能为空!',
  130. type: 'error',
  131. })
  132. }
  133. this.$api.doRequest('post', '/openServiceInfo/api/addInfo', this.personInfo).then(res => {
  134. if (res.data.code == 200) {
  135. this.$refs.uToast.show({
  136. title: '提交成功,客服人员会及时与您取得联系。!',
  137. type: 'success',
  138. back: true
  139. })
  140. }
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang='scss' scoped>
  147. page {
  148. background: #F5F6FA;
  149. overflow: hidden;
  150. }
  151. .wrap {
  152. background: #fff;
  153. margin: 10px;
  154. border-radius: 10px;
  155. padding: 20rpx;
  156. }
  157. .content {
  158. border-radius: 20rpx;
  159. background: white;
  160. padding: 20rpx;
  161. .row {
  162. display: flex;
  163. justify-content: space-between;
  164. border-bottom: 1px solid #EEEEEE;
  165. padding: 21rpx 0;
  166. .right,
  167. input {
  168. font-size: 28rpx;
  169. color: #333333;
  170. }
  171. }
  172. .row-bottom {
  173. .right-bottom {
  174. width: 300rpx;
  175. text-align: right;
  176. }
  177. }
  178. .no-boder {
  179. border: 0;
  180. }
  181. }
  182. .submit {
  183. margin-top: 200rpx;
  184. background: #22C572;
  185. border-radius: 10rpx;
  186. }
  187. </style>