details.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="container">
  3. <view class="content-box"><!-- @click="openAddress(item)" -->
  4. <view class="item">
  5. <view class="info flex_item">
  6. <view>头像:</view>
  7. <image :src="caller_info.avatar"></image>
  8. </view>
  9. <view class="info" v-if="list.status == 0 || list.status == 2">救援者姓名:救援者{{list.caller_info.helper}}</view>
  10. <view class="info" v-if="list.status == 1 || list.status == 3">救援者姓名:{{list.caller_info.nickname}}</view>
  11. <view class="info" v-if="list.status == 1 || list.status == 3">手机号:{{caller_info.mobile}}</view>
  12. <!-- <view class="info">求救信息:{{list.help_info}}</view> -->
  13. <view class="info">创建时间:{{list.createtime}}</view>
  14. <view class="info">状态:{{list.status_text}}</view>
  15. </view>
  16. <view class="box-btn flex" v-if="list.status == 0">
  17. <view class="accept" @click.stop="access(list)">接受</view>
  18. <view class="refuse" @click.stop="refuse(list)">拒绝</view>
  19. </view>
  20. <view class="box-btn flex" v-if="list.status == 1">
  21. <view class="accept" @click="success()">完成救援</view>
  22. <view class="refuse blue" @click="openAddress()">前往导航</view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { sosInfo,accessSos,refuseSos,successSos } from '@/api/record.js';
  29. import { getTime } from '@/utils/rocessor.js';
  30. export default {
  31. data() {
  32. return {
  33. list:'',
  34. id:'',
  35. caller_info:''
  36. };
  37. },
  38. onLoad(option) {
  39. this.id = option.id;
  40. },
  41. onShow() {
  42. this.loadData();
  43. },
  44. //下拉刷新
  45. onPullDownRefresh() {
  46. this.loadData();
  47. },
  48. methods: {
  49. loadData(){
  50. let obj = this;
  51. sosInfo({
  52. id:obj.id,
  53. }).then(({ data }) => {
  54. obj.list = data;
  55. obj.caller_info = data.caller_info;
  56. console.log(obj.caller_info)
  57. obj.list.createtime = getTime(data.createtime)
  58. })
  59. .catch(e => {
  60. console.log(e);
  61. });
  62. },
  63. openAddress(){
  64. let obj = this;
  65. uni.openLocation({
  66. latitude:+obj.list.lat,
  67. longitude:+obj.list.lng,
  68. success(e){
  69. console.log(e)
  70. },
  71. fail(e) {
  72. console.log(e);
  73. }
  74. })
  75. },
  76. //救援完成
  77. success(){
  78. let obj = this;
  79. successSos({
  80. id: obj.id
  81. }).then(( data ) => {
  82. console.log(data)
  83. obj.$api.msg(data.msg);
  84. obj.loadData();
  85. }).catch((e) => {
  86. obj.$api.msg(e.message);
  87. console.log(e)
  88. });
  89. },
  90. //同意救援
  91. access(){
  92. let obj = this;
  93. uni.showModal({
  94. title: '提示',
  95. content: '您确定要接受求救吗',
  96. success: function (res) {
  97. if (res.confirm) {
  98. accessSos({
  99. id: obj.id
  100. }).then((data) => {
  101. obj.$api.msg(data.msg);
  102. obj.loadData();
  103. }).catch((e) => {
  104. obj.$api.msg(e.message);
  105. console.log(e)
  106. });
  107. } else if (res.cancel) {
  108. console.log('用户点击取消');
  109. }
  110. }
  111. });
  112. },
  113. //拒绝救援
  114. refuse(){
  115. let obj = this;
  116. uni.showModal({
  117. title: '提示',
  118. content: '您确定要拒绝求救吗?',
  119. success: function (res) {
  120. if (res.confirm) {
  121. refuseSos({
  122. id: obj.id
  123. }).then((data) => {
  124. obj.loadData();
  125. }).catch((e) => {
  126. obj.$api.msg(e.message);
  127. });
  128. } else if (res.cancel) {
  129. console.log('用户点击取消');
  130. }
  131. }
  132. });
  133. },
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. page {
  139. background: #ffffff;
  140. height: 100%;
  141. .container{
  142. width: 100%;
  143. height: 100%;
  144. padding-top: 25rpx;
  145. }
  146. }
  147. .content-box {
  148. width: 100%;
  149. padding: 47rpx 30rpx;
  150. font-size: 28rpx;
  151. color: #666666;
  152. }
  153. .item{
  154. margin-bottom: 100rpx;
  155. }
  156. .info {
  157. font-size: 28rpx;
  158. color: #333333;
  159. font-weight: 500;
  160. padding: 28rpx 0rpx;
  161. border-bottom: 2rpx solid #F0F0F0;
  162. image{
  163. width: 100rpx;
  164. height: 100rpx;
  165. border-radius: 100%;
  166. }
  167. }
  168. .status {
  169. font-size: 28rpx;
  170. font-weight: bold;
  171. color: rgba(255, 79, 79, 1);
  172. }
  173. .box-btn{
  174. width: 80%;
  175. margin: 0rpx auto;
  176. .accept{
  177. background: #FF4F4F;
  178. border-radius: 50rpx;
  179. color: #FFFFFF;
  180. padding: 20rpx 70rpx;
  181. }
  182. .refuse{
  183. text-align: center;
  184. background: #F3F3F3;
  185. border-radius: 50rpx;
  186. padding: 20rpx 70rpx;
  187. }
  188. .blue{
  189. background: #6786FB;
  190. color: #FFFFFF;
  191. }
  192. }
  193. </style>