Grounding.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="page">
  3. <service-widget @btnClick="btn_click"></service-widget>
  4. <view class="address p-3 mb-4" @click="stopMap">
  5. <view class="title">
  6. <u-icon name="map" color="#2c2a35" size="38"></u-icon>
  7. <text>救援位置</text>
  8. </view>
  9. <view class="dis j-s a-start mt-2">
  10. <text style="width: 80%;color: #000;">{{dataInfo.rescuePosition}}</text>
  11. <u-icon name="arrow-right" color="#b0afb7" size="30" style="margin-top: 5px;"></u-icon>
  12. </view>
  13. </view>
  14. <view class="address p-3 mb-4">
  15. <text class="title">填写详细信息</text>
  16. <view class="mt-2 dis j-s a-c">
  17. <text style="width: 35%;">车牌号</text>
  18. <u-input style="width: 40%;" v-model="dataInfo.licencePlate" type="text" placeholder="请输入车牌号" />
  19. <u-icon name="arrow-right" color="#b0afb7" size="30"></u-icon>
  20. </view>
  21. <view class="mt-2 dis j-s a-c">
  22. <text style="width: 35%;">救援联系人</text>
  23. <u-input style="width: 40%;" v-model="dataInfo.rescueUser" type="text" placeholder="请输入联系人姓名" />
  24. </view>
  25. <view class="mt-2 dis j-s a-c">
  26. <text style="width: 35%;">联系人手机号</text>
  27. <u-input style="width: 40%;" v-model="dataInfo.phoneNumber" type="text" placeholder="请输入联系人手机号" />
  28. </view>
  29. </view>
  30. <view class="footerFixed dis j-s a-end">
  31. <view class="price">
  32. <text>¥</text>
  33. <text>{{dataInfo.rescueSum}}</text>
  34. <text>.00</text>
  35. </view>
  36. <view class="order dis a-c j-c" @click="plaorder">
  37. <text>立即购买</text>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. dataInfo: {
  47. rescuePosition: null, //救援地址
  48. rescueSum: "168", //救援金额
  49. licencePlate: "", //车牌号
  50. rescueUser: "", //联系人
  51. phoneNumber: "", //电话
  52. serveCode: "201",
  53. }
  54. }
  55. },
  56. onShow() {
  57. if (!this.dataInfo.rescuePosition) {
  58. this.getCurrentLocation();
  59. }
  60. },
  61. onLoad() {},
  62. methods: {
  63. btn_click() {
  64. uni.navigateTo({
  65. url: '/pages/chat/chat'
  66. })
  67. },
  68. getCurrentLocation() {
  69. //获取当前的地理位置
  70. let vthis = this;
  71. uni.getLocation({
  72. type: 'gcj02',
  73. geocode: true,
  74. success: function(res) {
  75. console.log(res);
  76. // uni.request({
  77. // url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${res.longitude},${res.latitude}&key=197d1a12301a306f82533a23651807b8`,
  78. // method: "GET",
  79. // success: (res) => {
  80. // console.log(res);
  81. // // this.addressList = res.data.pois;
  82. // // this.addressList.map(val => {
  83. // // val.distance = this.conversion(val.distance);
  84. // // return val;
  85. // // })
  86. // }
  87. // });
  88. let address = res.address.province + res.address.city + res.address.district + res
  89. .address.street + res.address.poiName;
  90. vthis.dataInfo.rescuePosition = address;
  91. },
  92. fail: function(err) {
  93. console.log(err);
  94. // #ifdef APP-PLUS
  95. uni.showModal({
  96. title: '提示',
  97. content: '请打开定位服务',
  98. success: ({
  99. confirm,
  100. cancel
  101. }) => {
  102. if (confirm) {
  103. // android平台
  104. if (uni.getSystemInfoSync().platform == 'android') {
  105. var Intent = plus.android.importClass(
  106. 'android.content.Intent');
  107. var Settings = plus.android.importClass(
  108. 'android.provider.Settings');
  109. var intent = new Intent(Settings
  110. .ACTION_LOCATION_SOURCE_SETTINGS);
  111. var main = plus.android.runtimeMainActivity();
  112. main.startActivity(intent); // 打开系统设置GPS服务页面
  113. }
  114. }
  115. // 用户取消前往开启定位服务
  116. if (cancel) {
  117. }
  118. }
  119. });
  120. // #endif
  121. }
  122. });
  123. },
  124. stopMap() {
  125. uni.navigateTo({
  126. url: "/pages/roadRescue/map"
  127. })
  128. },
  129. async plaorder() {
  130. let res = await this.$http.post('/ser/rescue/insert/rescueOrder', this.dataInfo);
  131. console.log(res);
  132. if (res.code == '200') {
  133. uni.showToast({
  134. title: '下单成功',
  135. duration: 2000,
  136. icon: "success"
  137. });
  138. }
  139. },
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .page {
  145. height: 100%;
  146. background-color: #f5f6f8;
  147. padding: 20px;
  148. }
  149. .address {
  150. background-color: white;
  151. .title {
  152. font-size: 18px;
  153. font-weight: bold;
  154. text {
  155. margin-left: 8px;
  156. }
  157. }
  158. }
  159. .footerFixed {
  160. position: fixed;
  161. bottom: 0;
  162. left: 0;
  163. right: 0;
  164. width: 100%;
  165. height: 60px;
  166. background-color: white;
  167. padding-left: 20px;
  168. view:first-child {
  169. width: 65%;
  170. }
  171. .price {
  172. color: #3267eb;
  173. font-weight: bold;
  174. font-size: 18px;
  175. }
  176. text:nth-child(2) {
  177. font-size: 34px;
  178. line-height: 1.2;
  179. }
  180. .order {
  181. width: 35%;
  182. height: 100%;
  183. background-color: #3267eb;
  184. color: #f5f6f8;
  185. font-size: 18px;
  186. }
  187. }
  188. </style>