signIn.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="signIn-wrap">
  3. <!-- 门店名称 -->
  4. <view class="module-con first-con">
  5. <text class="info-tit">门店名称:</text>
  6. <view class="info-main">
  7. <text class="location-addr">常青二路店</text>
  8. </view>
  9. </view>
  10. <!-- 定位 -->
  11. <view class="module-con">
  12. <text class="info-tit">当前位置:</text>
  13. <view class="info-main" @click="getLocation">
  14. <text class="location-addr">{{location}}</text>
  15. <u-icon name="map" color="#2979ff" size="34" class="location-icon"></u-icon>
  16. </view>
  17. </view>
  18. <!-- 拍照签到 -->
  19. <view class="module-con">
  20. <text class="info-tit">拍照签到:</text>
  21. <view class="info-main">
  22. <view class="photograph-con" @click="photograph ? null : goPhotograph()">
  23. <u-icon v-show="photograph" name="close-circle-fill" color="#fa3534" size="50" class="close-circle-icon" @click="cancelPhotograph"></u-icon>
  24. <u-icon v-show="!photograph" name="camera" color="#bfbfbf" size="60" class="photograph-icon"></u-icon>
  25. <u-image v-show="photograph" width="100%" height="100%" :src="photograph" @click="previewPictures"></u-image>
  26. </view>
  27. </view>
  28. </view>
  29. <u-button type="primary" class="submit-btn" @click="signInFun">签到并开始巡店</u-button>
  30. </view>
  31. </template>
  32. <script>
  33. import { clzConfirm } from '@/libs/tools.js'
  34. export default{
  35. data(){
  36. return{
  37. location: '', // 当前位置
  38. photograph: '', // 拍照
  39. }
  40. },
  41. onShow() {
  42. this.init()
  43. },
  44. methods: {
  45. // 初始化
  46. init(){
  47. this.getLocation()
  48. },
  49. // 获取当前位置
  50. getLocation(){
  51. const _this = this
  52. uni.getLocation({
  53. type: 'gcj02',
  54. geocode: true,
  55. success: function (res) {
  56. console.log(res)
  57. _this.location = res.address.province + res.address.city + res.address.district + res.address.street + res.address.streetNum +'靠近' + res.address.poiName
  58. console.log(_this.location, '城市编码 ', res.address.cityCode)
  59. }
  60. })
  61. },
  62. // 签到拍照
  63. goPhotograph(){
  64. const _this = this
  65. uni.chooseImage({
  66. count: 1, //最多可以选择的图片张数,默认9
  67. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  68. sourceType: ['camera'], //album 从相册选图,camera 使用相机,默认二者都有
  69. success: function (res) {
  70. // tempFilePaths 图片的本地文件路径列表,tempFiles 图片的本地文件列表,每一项是一个 File 对象
  71. console.log(JSON.stringify(res.tempFilePaths))
  72. _this.photograph = res.tempFilePaths[0]
  73. }
  74. })
  75. },
  76. // 签到
  77. signInFun(){
  78. // 判断是否超出签到范围
  79. const outRange = false
  80. if(outRange){
  81. this.isOutRange()
  82. }else{
  83. // 跳转 开始巡店
  84. uni.redirectTo({
  85. url: '/pages/shopTourOver/shopTourOver'
  86. })
  87. }
  88. },
  89. // 超出范围 提示
  90. isOutRange(){
  91. clzConfirm({
  92. title: '提示',
  93. content: '您所在的位置超出门店签到范围,无法开启巡店!',
  94. showCancel: false,
  95. success: function (res) {
  96. if (res.confirm||res.index==0) {
  97. }
  98. }
  99. })
  100. },
  101. // 预览签到图
  102. previewPictures(){
  103. const photograph = [this.photograph]
  104. uni.previewImage({
  105. urls: photograph
  106. })
  107. },
  108. // 删除签到图
  109. cancelPhotograph(){
  110. setTimeout(()=>{
  111. this.photograph = ''
  112. },500)
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. page{
  119. background-color: #f8f8f8;
  120. height: calc(100vh - 44px);
  121. }
  122. .signIn-wrap{
  123. height: 100%;
  124. .module-con{
  125. padding: 0 30upx 20upx;
  126. .info-main{
  127. margin-top: 14upx;
  128. padding: 20upx;
  129. border-radius: 12upx;
  130. background-color: #fff;
  131. .location-addr{
  132. font-size: 24upx;
  133. }
  134. .location-icon{
  135. padding-left: 10upx;
  136. vertical-align: bottom;
  137. }
  138. .photograph-con{
  139. border: 2upx dashed #bfbfbf;
  140. border-radius: 12upx;
  141. width: 160upx;
  142. height: 160upx;
  143. text-align: center;
  144. position: relative;
  145. .photograph-icon{
  146. display: inline-block;
  147. padding-top: 48upx;
  148. }
  149. .close-circle-icon{
  150. background-color: #fff;
  151. border-radius: 50%;
  152. position: absolute;
  153. right: -23upx;
  154. top: -23upx;
  155. z-index: 9;
  156. }
  157. }
  158. }
  159. }
  160. .first-con{
  161. padding-top: 30upx;
  162. }
  163. .submit-btn{
  164. width: 80%;
  165. margin-top: 50upx;
  166. }
  167. }
  168. </style>