Grounding.vue 4.7 KB

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