sign_in.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view>
  3. <view class="scan_code flexCC">
  4. <view class="title">扫码签到</view>
  5. <view class="intr">管理员用微信扫描报名凭证进行签到</view>
  6. <view class="btn flexC" @click="scanCode">
  7. <text class="iconfont iconsaoma" style="color:#fff;font-size:50rpx;margin-right:10rpx;"></text>
  8. <text>扫码签到</text>
  9. </view>
  10. </view>
  11. <view class="manual">
  12. <view class="title">验证码签到</view>
  13. <view class="intr">管理员输入报名验证码进行签到</view>
  14. <view class="inp flexB">
  15. <input type="text" placeholder="请输入报名验证码" v-model="code" />
  16. <view class="flexCC" @click="checkout">确认</view>
  17. </view>
  18. <view class="info" v-if="showInfo">
  19. <view>信息确认:</view>
  20. <view class="flexS">
  21. <text>报名人:</text>
  22. <view>{{ signInfo.nickname }}</view>
  23. </view>
  24. <view class="flexS">
  25. <text>手机号:</text>
  26. <view>{{ signInfo.phone }}</view>
  27. </view>
  28. <view class="flexS">
  29. <text>报名时间:</text>
  30. <view>{{ signInfo.created_at }}</view>
  31. </view>
  32. </view>
  33. <view class="btn flexC" @click="sureSign">
  34. <image src="../../static/imgs/signIn.png" mode=""></image>
  35. <text>确认签到</text>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { getUser, sureSign } from '../../api/sign_in.js';
  42. export default {
  43. data() {
  44. return {
  45. showInfo: false, //是否显示报名信息
  46. code: '', //验证码
  47. signInfo: '' //报名人信息
  48. };
  49. },
  50. methods: {
  51. /*扫码签到
  52. * @params id 扫描小程序码截取的id
  53. */
  54. scanCode() {
  55. uni.scanCode({
  56. success: res => {
  57. let str = res.path;
  58. let id = str.replace(/[^0-9]/gi, '');
  59. if (id) {
  60. //判断有没有签到权限
  61. getUser({ id }).then(res => {
  62. if (res.code != 200) {
  63. uni.showModal({
  64. content: res.message,
  65. showCancel: false
  66. });
  67. return false;
  68. }
  69. if (res.code == 200) {
  70. uni.navigateTo({
  71. url: '../sign_in_voucher/sign_in_voucher?id=' + id
  72. });
  73. }
  74. });
  75. }
  76. }
  77. });
  78. },
  79. /*获取用户信息
  80. *@params code 输入的签到验证码
  81. */
  82. checkout() {
  83. if (!this.code) {
  84. uni.showModal({
  85. content: '请先输入验证码',
  86. showCancel: false
  87. });
  88. return false;
  89. }
  90. getUser({ code: this.code }).then(res => {
  91. if (res.code != 200) {
  92. uni.showModal({
  93. content: res.message,
  94. showCancel: false
  95. });
  96. this.code = '';
  97. return false;
  98. }
  99. if (res.code == 200) {
  100. this.showInfo = true;
  101. this.signInfo = res.data;
  102. }
  103. });
  104. },
  105. /*确认签到
  106. *@params id 输入验证码获取的id
  107. */
  108. sureSign() {
  109. if (!this.code) {
  110. uni.showModal({
  111. content: '请先输入验证码',
  112. showCancel: false
  113. });
  114. return false;
  115. }
  116. if (!this.signInfo) {
  117. uni.showModal({
  118. content: '请先获取报名信息',
  119. showCancel: false
  120. });
  121. return false;
  122. }
  123. sureSign({ id: this.signInfo.id }).then(res => {
  124. if (res.code != 200) {
  125. uni.showModal({
  126. content: res.message || '请求失败',
  127. showCancel: false
  128. });
  129. return false;
  130. }
  131. if (res.code == 200) {
  132. let { nickname, created_at, phone, season, type } = this.signInfo;
  133. uni.showToast({
  134. title: '签到成功!',
  135. duration: 2000,
  136. success: res => {
  137. uni.navigateTo({
  138. url:
  139. '../written_off/written_off?nickname=' +
  140. nickname +
  141. '&phone=' +
  142. phone +
  143. '&created_at=' +
  144. created_at +
  145. '&path=' +
  146. 2 +
  147. '&season=' +
  148. season +
  149. '&type=' +
  150. type
  151. });
  152. }
  153. });
  154. }
  155. });
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="scss">
  161. .manual,
  162. .scan_code {
  163. .title {
  164. font-size: 36rpx;
  165. color: #333;
  166. padding-top: 38rpx;
  167. }
  168. .intr {
  169. font-size: 26rpx;
  170. color: #666666;
  171. margin: 40rpx 0 23rpx 0;
  172. }
  173. .btn {
  174. width: 580rpx;
  175. margin: 0 auto;
  176. background-color: #ea4a41;
  177. height: 90rpx;
  178. border-radius: 45rpx;
  179. color: #fff;
  180. font-size: 32rpx;
  181. image {
  182. height: 42rpx;
  183. width: 42rpx;
  184. margin-right: 19rpx;
  185. }
  186. text {
  187. letter-spacing: 5rpx;
  188. }
  189. }
  190. }
  191. .scan_code {
  192. height: 300rpx;
  193. width: 100%;
  194. background-color: #fff;
  195. padding-bottom: 30rpx;
  196. }
  197. .manual {
  198. margin: 40rpx auto 0;
  199. background-color: #fff;
  200. padding-bottom: 30rpx;
  201. .title,
  202. .intr {
  203. text-align: center;
  204. }
  205. .btn {
  206. margin: 30rpx auto 0;
  207. }
  208. .inp {
  209. width: 690rpx;
  210. margin: 35rpx auto;
  211. border-radius: 6rpx;
  212. background-color: #f2f4f5;
  213. height: 105rpx;
  214. box-sizing: border-box;
  215. view {
  216. width: 128rpx;
  217. height: 64rpx;
  218. background-color: #ea4a41;
  219. border-radius: 32rpx;
  220. color: #fff;
  221. margin-right: 23rpx;
  222. letter-spacing: 3rpx;
  223. }
  224. input {
  225. width: 75%;
  226. height: 93%;
  227. margin-left: 48rpx;
  228. font-size: 36rpx;
  229. color: #333;
  230. }
  231. }
  232. .info {
  233. margin-left: 79rpx;
  234. font-size: 28rpx;
  235. > view {
  236. margin-top: 34rpx;
  237. }
  238. view {
  239. color: #333;
  240. }
  241. text {
  242. color: #666666;
  243. }
  244. }
  245. }
  246. </style>