openService.vue 4.4 KB

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