forhelp.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="container">
  3. <view class="title-box">
  4. <view>严重危害生命财产安全</view>
  5. <view>求助专属通道</view>
  6. </view>
  7. <view class="count">平台将为您:保留实时位置、通知平台联系人</view>
  8. <view class="but"><button @click="goforhelp">紧急求助</button></view>
  9. <view class="count">
  10. <view>生命财产安全受到侵害、严重威胁时使用</view>
  11. <view>有必要时,平台将为您报110</view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. latitude: "",
  20. longitude: ""
  21. }
  22. },
  23. onLoad() {
  24. },
  25. onShow: function(e) {
  26. var _this = this
  27. wx.authorize({
  28. scope: 'scope.userFuzzyLocation',
  29. success: res => {
  30. //console.log(res)
  31. wx.getFuzzyLocation({
  32. type: 'wgs84',
  33. success (res) {
  34. _this.longitude = res.longitude;
  35. _this.latitude = res.latitude;
  36. }
  37. });
  38. },
  39. fail: res => {
  40. //console.log('失败:', res);
  41. }
  42. });
  43. },
  44. methods: {
  45. goforhelp: function(goforhelp) {
  46. var _this = this
  47. _this.$request.post('forhelp.add', {
  48. samkey: (new Date()).valueOf(),
  49. longitude: _this.longitude,
  50. latitude: _this.latitude
  51. }).then(res => {
  52. if (res.errno == 0) {
  53. uni.showModal({
  54. title: '提示',
  55. content: res.msg,
  56. showCancel: false,
  57. //是否显示取消按钮
  58. success: function(res) {
  59. }
  60. });
  61. }
  62. })
  63. }
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function() {
  69. setTimeout(() => {
  70. uni.stopPullDownRefresh()
  71. }, 200);
  72. },
  73. onReachBottom() {}
  74. }
  75. </script>
  76. <style>
  77. page {
  78. background-color: #fab74e;
  79. }
  80. .container {
  81. color: #ffffff;
  82. text-align: center;
  83. }
  84. .title-box {
  85. padding-top: 100rpx;
  86. font-size: 50rpx;
  87. font-weight: bold;
  88. }
  89. .count {
  90. padding-top: 30rpx;
  91. font-size: 28rpx;
  92. line-height: 38rpx;
  93. }
  94. .but {
  95. padding-top: 100rpx;
  96. }
  97. .but button {
  98. background-color: #ffffff;
  99. color: #fab74e;
  100. border-radius: 150rpx;
  101. width: 300rpx;
  102. height: 300rpx;
  103. line-height: 300rpx;
  104. }
  105. </style>