Grounding.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. let address = res.address.province + res.address.city + res.address.district + res
  71. .address.street + res.address.poiName;
  72. vthis.dataInfo.rescuePosition = address;
  73. },
  74. fail: function(err) {
  75. console.log(err);
  76. // #ifdef APP-PLUS
  77. uni.showModal({
  78. title: '提示',
  79. content: '请打开定位服务',
  80. success: ({
  81. confirm,
  82. cancel
  83. }) => {
  84. if (confirm) {
  85. // android平台
  86. if (uni.getSystemInfoSync().platform == 'android') {
  87. var Intent = plus.android.importClass(
  88. 'android.content.Intent');
  89. var Settings = plus.android.importClass(
  90. 'android.provider.Settings');
  91. var intent = new Intent(Settings
  92. .ACTION_LOCATION_SOURCE_SETTINGS);
  93. var main = plus.android.runtimeMainActivity();
  94. main.startActivity(intent); // 打开系统设置GPS服务页面
  95. }
  96. }
  97. // 用户取消前往开启定位服务
  98. if (cancel) {
  99. uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
  100. delta: 1
  101. });
  102. }
  103. }
  104. });
  105. // #endif
  106. }
  107. });
  108. },
  109. stopMap() {
  110. uni.navigateTo({
  111. url: "/pages/roadRescue/map"
  112. })
  113. },
  114. async plaorder() {
  115. let res = await this.$http.post('/ser/rescue/insert/rescueOrder', this.dataInfo);
  116. console.log(res);
  117. if (res.code == '200') {
  118. uni.showToast({
  119. title: '下单成功',
  120. duration: 2000,
  121. icon: "success"
  122. });
  123. }
  124. },
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .page {
  130. height: 100%;
  131. background-color: #f5f6f8;
  132. padding: 20px;
  133. }
  134. .address {
  135. background-color: white;
  136. .title {
  137. font-size: 18px;
  138. font-weight: bold;
  139. text {
  140. margin-left: 8px;
  141. }
  142. }
  143. }
  144. .footerFixed {
  145. position: fixed;
  146. bottom: 0;
  147. left: 0;
  148. right: 0;
  149. width: 100%;
  150. height: 60px;
  151. background-color: white;
  152. padding-left: 20px;
  153. view:first-child {
  154. width: 65%;
  155. }
  156. .price {
  157. color: #3267eb;
  158. font-weight: bold;
  159. font-size: 18px;
  160. }
  161. text:nth-child(2) {
  162. font-size: 34px;
  163. line-height: 1.2;
  164. }
  165. .order {
  166. width: 35%;
  167. height: 100%;
  168. background-color: #3267eb;
  169. color: #f5f6f8;
  170. font-size: 18px;
  171. }
  172. }
  173. </style>